WordPress.org

Ready to get started?Download WordPress

Forums

Replace Featured Image with Video
Featured Video Box Missing for Posts (68 posts)

  1. aaronmolnar1
    Member
    Posted 2 years ago #

    I can see the featured video box when editing pages but it's not there for Posts. Anything I can do?

    http://wordpress.org/extend/plugins/replace-featured-image-with-video/

  2. jersahi
    Member
    Posted 2 years ago #

    i have the same problem

  3. Markus Stefanko
    Member
    Posted 2 years ago #

    What I did to fix this issue was editing the replace-featured-image-with-video/pt-page-featured-video.php file

    Replace

    function add_fv_box_fields() {
        add_meta_box( 'docs_list', __( 'Featured Video', 'related-video' ), 'admin_fv_box_html', 'page', 'side' );
    }

    with

    function add_fv_box_fields() {
        add_meta_box( 'docs_list', __( 'Featured Video', 'related-video' ), 'admin_fv_box_html', 'page', 'side' );
        add_meta_box( 'docs_list', __( 'Featured Video', 'related-video' ), 'admin_fv_box_html', 'post', 'side' );
    }
  4. Markus Stefanko
    Member
    Posted 2 years ago #

    I'm not sure if it's the right way, since it doesn't automatically implement into my post. I have a hunch that the plugin might not be finished yet.

    So I had to fix the single.php template with the following :

    if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
     echo get_post_meta(get_the_ID(), "_related-video", true);
    }else{
     the_post_thumbnail( 'main' );
    }

    Replace that with your the_post_thumbnail('main') in single.php. 'main' could be also something else, depending on your thumbnail definitions in functions.php.

  5. isshepherdmusic
    Member
    Posted 1 year ago #

    I also have this problem (featured video showing on page but not post). What a shame, would be a great plugin if it gets fixed?

  6. Markus Stefanko
    Member
    Posted 1 year ago #

    Well if you apply my fix, it will work.

  7. sclinclin
    Member
    Posted 1 year ago #

    Disagree I need your help. I tried your fix, but it keeps showing me the video on the page, but no as a thumbnail in the frontpage.

    I'm using a theme called "Gridly".

    I think I'm doing something wrong on the "single.php"

    This is what I do with your fix:

    <div class="gridly-image">
    <?php if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
    echo get_post_meta(get_the_ID(), "_related-video", true);
    }else{
    the_post_thumbnail( 'summary-image' );
    }  ?>
    </div>

    This is how it looks without your fix:

    <div class="gridly-image"><?php the_post_thumbnail( 'detail-image' ); ?></div>

    I hope you can give a hand, it's killing me!!! Thanks you!!!

  8. Markus Stefanko
    Member
    Posted 1 year ago #

    If it looks like this without my fix, then you should change the_post_thumbnail( 'summary-image' ); to the_post_thumbnail( 'detail-image' );.

    But all my fix does is replacing the featured image in the post, with the video. No other thumbnails are effected - they will still show the featured image in the thumbnail.

    From what I've seen, this plugin does not have any code to actually work with the videos. It simply adds the embed code to a post, nothing more, nothing less.

  9. wellbeingtips
    Member
    Posted 1 year ago #

    I have the same problem. Im using child theme and I dont know how to fix it with your fix "disagree". Any Idea?

  10. Mikkel Breum
    Member
    Posted 1 year ago #

    I can confirm that the plugin dos not work for posts. (WP v.3.4.1) Would be good to hear from the developer regarding this.

  11. jomad205
    Member
    Posted 1 year ago #

    How can we solve it? :S I have the same problem, I have edited the replace-featured-image-with-video/pt-page-featured-video.php file, and now appears the box in the Post , but when I publish it... 'NO VIDEO', no... nothing.

  12. Mikkel Breum
    Member
    Posted 1 year ago #

    you have to add the code mentioned by @disagree to your relevant template files as well.

    Anywhere where it outputs the image thumbnails you want to replace, you need it to check if a video embed code is specified, and if it it, render that instead of the featured image. It looks like this:

    if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
        echo get_post_meta(get_the_ID(), "_related-video", true);
    }else{
        the_post_thumbnail( 'main' );
    }
  13. Florence
    Member
    Posted 1 year ago #

    Hello!
    Thank you for the fix!
    I have little to no experience with coding but the first step worked! I now have the featured image box when I go to write posts. This is quite an accomplishment for me :)

    I don't understand the second step though. In single.php the featured image is put out like this:

    <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { /* if post has a thumbnail */ ?>
    				<?php the_post_thumbnail('post-thumb', array('class' => 'post-thumb')); ?>
    				<?php } ?>

    What exaclty do I need to do with in order to replace the featured image with a video (only if I inserted a code in the 'featured video' box)?

  14. Mikkel Breum
    Member
    Posted 1 year ago #

    @Florence

    You can replace the code you have with this:

    <?php
    if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
       // show the video embed code if there is one
        echo get_post_meta(get_the_ID(), "_related-video", true);
    }else{
       if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) {
        // show the image thumb if there is one, and the post does not have a video
        the_post_thumbnail('post-thumb', array('class' => 'post-thumb'));
       }
    }
    ?>
  15. Florence
    Member
    Posted 1 year ago #

    Never mind! I figured it out on my own! Thanks

  16. Florence
    Member
    Posted 1 year ago #

    Oh woops, Mikkel, I hadn't noticed your reply. This is what I did:

    <?php if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
    echo get_post_meta(get_the_ID(), "_related-video", true);
    }else{
    the_post_thumbnail( 'post-thumb' );
    }  ?>

    But yours looks better! I didn't know how to incorporate both functions. But now I think I understand a little better. Thank you. Maybe next time I can do it without help :)

  17. Mikkel Breum
    Member
    Posted 1 year ago #

    @Florence cool, it's always a joy to learn, and to make it work on your own :)

  18. Swwils
    Member
    Posted 1 year ago #

    Hey, I have the same problem.
    My theme is using a really strange way of thumbnail generation:

    <?php
    	if ( has_post_thumbnail() ) {
                the_post_thumbnail('blog-large', array('title' => ''.get_the_title().''));
    	?><span class="tail-large">&nbsp;</span><?php
    	}
    ?>

    How do I apply this fix? And also it is generating the standard "Set featured image" and another seperate "Featured Video" window.

    Thanks!

  19. Mikkel Breum
    Member
    Posted 1 year ago #

    @Swwils the code in your theme is fine, it's just telling the function 'the_post_thumbnail' what size to show the image in and use the title of the post as the title for the image. then it adds a bit of html at the end:

    <span class="tail-large"> </span>

    To use the Featured Video, you paste your video embed code in the Featured Video text box in the editing screen of the post, and save it.

    In your themes template file, you replace your code with this:

    <?php
    if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
    
       // show the video embed code if there is one
        echo get_post_meta(get_the_ID(), "_related-video", true);
        ?><span class="tail-large"> </span><?php
    
    }else{
    
       if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) {
    
        // show the image thumb if there is one, and the post does not have a video
        the_post_thumbnail('blog-large', array('title' => ''.get_the_title().''));
    	?><span class="tail-large"> </span><?php
    
       }
    
    }
    ?>
  20. Swwils
    Member
    Posted 1 year ago #

    That worked a treat! Thanks very much.

    I've used the same method to push the fix over to the actual blog page; but im having issue with an hyperlink covering the video.

    <div id="post-<?php the_ID(); ?>" <?php post_class($class); ?>>
    									<div class="view view-first">
    										<a href="<?php the_permalink(); ?>">
    											<?php
    												if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
     echo get_post_meta(get_the_ID(), "_related-video", true);
    }else{
     the_post_thumbnail( 'blog-medium' );
    }?>
    </a>
    										<div class="mask">
    				                        	<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="more-blog">
    						   						<img src="<?php echo get_template_directory_uri(); ?>/img/icons/link.png" alt="read more" title="read more" />
    						   					</a>
    				                    	</div>
    									</div>
    									<?php
    										if ( has_post_thumbnail() ) {
    											?><span class="tail"> </span><?php
    										}
    									?>

    How can I get the to only enclose a thumbnail and not the video? - (Its a css on hover class)

  21. Mikkel Breum
    Member
    Posted 1 year ago #

    @swwils from what you describe, it sound like you have to move the < a > tag to the part of the conditional statement where you add the thumbnail. Take a look at what's actually going on:

    if there is a video
    // show the video embed code
    else
    // show the image thumb if there is one

    So you ned to move you < a href ... tag to the laft part of the if...else clause, so it only gets printet if there is a thumbnail, and not if there is a video..

  22. zombiefred
    Member
    Posted 1 year ago #

    Any chance you can help me figure out where to paste?

    /**
      * Checks for images using a custom version of the WordPress 2.9+ get_the_post_thumbnail() function.
      * If an image is found, return it and the $post_thumbnail_id.  The WordPress function's other filters are
      * later added in the display_the_image() function.
      *
      */
     function imwb_interest_image_post_thumbnail( $args = array() ) {
    
        /* Check for a post image ID (set by WP as a custom field). */
        $post_tid = get_post_thumbnail_id( $args['post_id'] );
    
        /* If no post image ID is found, return false. */
        if ( empty( $post_tid ) )
        	return false;
    
        /* Apply filters on post_thumbnail_size because this is a default WP filter used with its image feature. */
        $size = apply_filters( 'post_thumbnail_size', $args['size'] );
    
        /* Get the attachment image source.  This should return an array. */
        $image = wp_get_attachment_image_src( $post_tid, $size );
    
        return $image[0];
     }

    Thanks!

  23. sadhaka
    Member
    Posted 1 year ago #

    I have the same theme as Florence. I updated the /replace-featured-image-with-video/pt-page-featured-video.php file as "disagree" suggested and got the box to insert the video embed code - great.

    But then I was in the same situation as Florence. In single.php, I replaced:

    <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { /* if post has a thumbnail */ ?>
    				<?php the_post_thumbnail('post-thumb', array('class' => 'post-thumb')); ?>
    				<?php } ?>

    ... with Mikkel's code suggestion (not the one Florence initially tried), i.e., this:

    <?php
    if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
       // show the video embed code if there is one
        echo get_post_meta(get_the_ID(), "_related-video", true);
    }else{
       if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) {
        // show the image thumb if there is one, and the post does not have a video
        the_post_thumbnail('post-thumb', array('class' => 'post-thumb'));
       }
    }
    ?>

    ... but now, although the post itself shows the video OK as the featured image, the thumbnail image in the home loop shows the other featured image - the still picture one (not the video thumbnail). If I remove that still featured image, but keep the embed code, the home loop shows no thumbnail at all. (I suppose I could make a still featured image picture shot of the video, but I'd like to get it done properly.)

    So Florence, how did you get the home loop thumbnail to work (as well as the post featured image) with the foodpress theme?

    I notice that in foodpress's single.php, there is more than one instance of:

    <?php
    if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  )
    ?>

    The first is in the code chunk that Florence replaced. The second looks like this:

    <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { /* if post has a thumbnail */ ?>
    					<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_post_thumbnail('grid-thumb'); ?></a>
    					<?php } ?>

    ... should that be changed as well, to show the home loop thumbnail? (Though do I get the impression that Florence managed to show the home loop thumbnail without changing that extra bit of code?).

    So near yet so far!

  24. sadhaka
    Member
    Posted 1 year ago #

    @Florence - the second instance of that code snippet is to do with the "related posts" thumbnails.

    I still can't get the "video thumbnail" to show in the main loop. I can only get a "normal" still image featured image to show there, if I insert one as well as the video embed code.

  25. sadhaka
    Member
    Posted 1 year ago #

    I think I understand what's going on. This plugin does not change the smaller thumbnails on the home page or anywhere else; it only overrides the featured image on the post page into a video. And, I guess, the only way to match the smaller thumbnails on other pages like the home page to the appearance of the video picture is to 'fake it' by matching the "real" featured image to the video keyframe.

    If I've got this wrong, then someone please enlighten me.

  26. Florence
    Member
    Posted 1 year ago #

    Hi Sadhaka. I'm cooking dinner right now. And tonight I have some friends coming over. I'll help you as soon as I've got time. If not tonight, I'll definitely get back to you tomorrow.

  27. PurpleTurtlePro
    Member
    Plugin Author

    Posted 1 year ago #

    Hey guys sorry for the tardy response.. We made the plugin for a client and i had no idea anyone would actually use it lol.. we should have it finished soon..

    If your using any theme with a large header.. pasting this above <div id="primary"> on the page.php and the single.php should do the trick:

    <?php
    				// Check to see if the header image has been removed
    				$header_image = get_header_image();
    				if ( ! empty( $header_image ) ) :
    			?>
    				<?php
    					// The header image
    					// Check if this is a post or page, if it has a thumbnail, and if it's a big one
    					if ( is_singular() &&
    							has_post_thumbnail( $post->ID ) &&
    							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ) ) &&
    							$image[1] >= HEADER_IMAGE_WIDTH ) :
    						// Houston, we have a new header image!
    						echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
    					else : ?>
    					<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    				<?php endif; // end check for featured image or standard header ?>
    			<?php endif; // end check for removed header image ?>
  28. PurpleTurtlePro
    Member
    Plugin Author

    Posted 1 year ago #

    ok you should go to header.php and find that header image area

    then apply that:

    $rel_video = get_post_meta( $post->ID, '_related-video', true );
    
    if ( strlen($rel_video) ) {
        echo $rel_video;
    } else {
    
        // your original header image codes
        // .......
        // .......
        // .......
    
    }

    It's all that..

  29. PurpleTurtlePro
    Member
    Plugin Author

    Posted 1 year ago #

    don't double slash your header image codes btw.. not to disable them

  30. Florence
    Member
    Posted 1 year ago #

    @sadhaka
    Hi. I suggest you revert back to an older back-up, because I didn't have the issues you're describing. If you follow these directions, it should work.

    First I used Dissagree's fix to make the box show up in the edit post pages. Go to replace-featured-image-with-video/pt-page-featured-video.php and replace

    function add_fv_box_fields() {
        add_meta_box( 'docs_list', __( 'Featured Video', 'related-video' ), 'admin_fv_box_html', 'page', 'side' );
    }

    with

    function add_fv_box_fields() {
        add_meta_box( 'docs_list', __( 'Featured Video', 'related-video' ), 'admin_fv_box_html', 'page', 'side' );
        add_meta_box( 'docs_list', __( 'Featured Video', 'related-video' ), 'admin_fv_box_html', 'post', 'side' );
    }

    Then go to your single.php and find the code that puts out the featured image above the post content

    <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { /* if post has a thumbnail */ ?>
    				<?php the_post_thumbnail('post-thumb', array('class' => 'post-thumb')); ?>
    				<?php } ?>

    with Mikkel's code:

    <?php
    if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
       // show the video embed code if there is one
        echo get_post_meta(get_the_ID(), "_related-video", true);
    }else{
       if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) {
        // show the image thumb if there is one, and the post does not have a video
        the_post_thumbnail('post-thumb', array('class' => 'post-thumb'));
       }
    }
    ?>

    Oh hahah! I hadn't noticed your last comment! Yeah if that's what you want to achieve, faking it would probably be the best solution.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic