Plugin Author
Alex
(@ahoereth)
The featured image is not replaced by the featured video.
You modified the original theme? Than it should be no problem for you to integrate the featured video plus plugin as well:
All you need to do is find the place where the featured images is added to the posts/pages. Then put the code which echos the image in a conditional which either prints the video or the image when no video is available.
Here an example for the Zoren theme: http://www.diffchecker.com/avknjdqn
On the left side is the original code. On the right I added
if(function_exists('has_post_video') && has_post_video()):
the_post_video();
else: [...] endif;
[…] contains all the normal featured image stuff.
Please report back if this works or if I can help further!
Alex
Thread Starter
jstanj
(@jstanj)
Thanks. I’m not super great with php, but does this look correct?
ORIGINAL
<?php if(get_option_tree('show_featured_image') == 'Yes') : ?>
<?php if (has_post_thumbnail( $post->ID )) {
// Grab the URL for the thumbnail (featured image)
$thumb = get_post_thumbnail_id();
$image_full = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
$imgheight = ot_get_option('default_image_height', $theme_options, false, true, 0 );
$image = vt_resize( $thumb, '', 700, $imgheight, true );
// Check for a lightbox link, if it exists, use that as the value.
// If it doesn't, use the featured image URL from above.
if(get_custom_field('lightbox_link')) {
$lightbox_link = get_custom_field('lightbox_link');
} else {
$lightbox_link = $image_full[0];
} ?>
<a href="<?php echo $lightbox_link; ?>" data-rel="prettyPhoto[<?php echo $post_slug; ?>]">
<img class="aligncenter" src="<?php echo $image[url]; ?>" width="<?php echo $image[width]; ?>" height="<?php echo $image[height]; ?>" alt="<?php the_title(); ?>" />
</a>
<br class="clearfix" />
<?php } else {} ?>
<?php endif; ?>
EDITED
<?php if(get_option_tree('show_featured_image') == 'Yes') : ?>
<?php if(function_exists('has_post_video') && has_post_video()):
the_post_video();
else:
if (has_post_thumbnail( $post->ID )) {
// Grab the URL for the thumbnail (featured image)
$thumb = get_post_thumbnail_id();
$image_full = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
$imgheight = ot_get_option('default_image_height', $theme_options, false, true, 0 );
$image = vt_resize( $thumb, '', 700, $imgheight, true );
// Check for a lightbox link, if it exists, use that as the value.
// If it doesn't, use the featured image URL from above.
if(get_custom_field('lightbox_link')) {
$lightbox_link = get_custom_field('lightbox_link');
} else {
$lightbox_link = $image_full[0];
}
?>
<a href="<?php echo $lightbox_link; ?>" data-rel="prettyPhoto[<?php echo $post_slug; ?>]">
<img class="aligncenter" src="<?php echo $image[url]; ?>" width="<?php echo $image[width]; ?>" height="<?php echo $image[height]; ?>" alt="<?php the_title(); ?>" />
</a>
<br class="clearfix" />
<?php } else {} ?>
<?php endif; ?>
Plugin Author
Alex
(@ahoereth)
Yea for clean php you could merge
else:
if (has_post_thumbnail( $post->ID )) {
to
elseif(has_post_thumbnail( $post->ID )) :
And then change
<?php } else {} ?>
<?php endif; ?>
to just
<?php endif; ?>
Also check if you have as many endif’s and }’s as “if :”‘s and {‘s 😉
If the layout breaks try adding
echo '<br class="clearfix" />;'
behind the_post_video().
Alex
Thread Starter
jstanj
(@jstanj)
That did it, thanks!
Thanks for the tip about php as well. I assumed you close it out like everything else, just haven’t taking the time to learn what those tages are yet.
Cheers,
Jason