Hover images and Videos
-
Hi all,
I got this code to show video loops on my blog. It’s working nicely.
Function.php
function catch_video() { global $post, $posts; $first_vid = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<iframe.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_vid = $matches [1] [0]; echo '<iframe width="100%" height="400" src="'; echo $first_vid; echo '" frameborder="0" allowfullscreen></iframe>'; }It is shown by the code in the loop: <?php catch_video();?>
Now, I would like that when it was posted a featured image instead of the video, it showed a code of mouse hover (I already have it ready), so I created this code but something is wrong with it:
<?php $blog = new WP_Query($args); ?> <?php while( have_posts() ): the_post(); ?> <?php if(has_post_thumbnail()): ?> <!-- Hover Image --> <div class="image-wrapper-hover"> <!-- hover-content --> <?php the_post_thumbnail('large');?> </div> <!-- close Hover Image --> <?php else ?> <?php catch_video();?> <?php endif ?>Anyone knows what is wrong?
The topic ‘Hover images and Videos’ is closed to new replies.