WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. sadhaka
    Member
    Posted 1 year ago #

    @Florence

    Thanks for taking the time to go through that step by step. In fact, it looks like I did make exactly the changes you describe.

    I was getting confused (and I probably confused everyone here as well) because I thought the plugin somehow changed the smaller thumbnails on other pages (e.g., the home page "latest" loop) as well - but of course it doesn't!

    I was under that impression because the home page thumbnails on your site looked just like the video preview/keyframe in your post page. So was that coincidence, or did you 'fake it' and match the two images as well?

  2. Florence
    Member
    Posted 1 year ago #

    There are maybe a couple where I used a frame from the video as a thumb because I couldn't find a better picutre. If there are any other features on my site you like, leave a comment and I'll tell you how I did it.
    Cheers!

  3. sadhaka
    Member
    Posted 1 year ago #

    Ah, I thought so - good idea. It's a great site, I like it a lot. I will leave some comments on it! Thanks.

  4. sadhaka
    Member
    Posted 1 year ago #

    Hey Florence - not sure how to contact you via your site - was going to ask you if the jetpack plugin plays OK with your theme...

  5. Florence
    Member
    Posted 1 year ago #

    Just leave a comment with you emailadress and I'll email you. I'd rather not post my emailadress on this forum, or any forum for that matter.
    You can get Jetpack to work, but you'll need to make a few changes to the theme.

  6. sadhaka
    Member
    Posted 1 year ago #

    Florence I find it impossible to leave comments on your site - they're not working - error 403 every time (is this jetpack causing problems?). You can email me at: temp22102012@glastonburymagic.com - I'll delete this email account after I hear from you. Cheers

  7. Florence
    Member
    Posted 1 year ago #

    email sent :)

  8. newzy
    Member
    Posted 1 year ago #

    Dear Everyone,

    Thanks for all these insights however i am facing some issue placing the second part of the code and should amend the code on the index page directly.

    Here is the code I have their:

    <?php if (have_posts()) : ?>
    <div id="post-area">
    
    <?php while (have_posts()) : the_post(); ?>	
    
       		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		 <?php if ( has_post_thumbnail() ) { ?>
             <div class="gridly-image"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail( 'summary-image' );  ?></a></div>
              <div class="gridly-category"><p><?php the_category(', ') ?></p></div>
    
    		  <?php } ?>
           			<div class="gridly-copy"><h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
                    <p class="gridly-date"><?php the_time(get_option('date_format')); ?>  </p>
    
    <?php the_excerpt(); ?> 
    
                   <p class="gridly-link"><a href="<?php the_permalink() ?>">View more &rarr;</a></p>
             </div>
           </div>
    
    <?php endwhile; ?>
    </div>
    <?php else : ?>
    <?php endif; ?>

    If you can help me getting this nice video in place.

    Thanks

  9. Jonathancairns
    Member
    Posted 1 year ago #

    Hello everyone

    I am having great issues with getting this plug-in to work with the 'Hatch' theme

    Link to Hatch theme

    the theme does not have a single.php file and whilst i can get the first fix to display the 'featured video' box in edit post i cannot get the video to display either in the post or as featured video.

    can anyone please shed some light on a possible fix

  10. Florence
    Member
    Posted 1 year ago #

    no single php? Does it have a page.php? Which file is used to display posts, do you know?

  11. Jonathancairns
    Member
    Posted 1 year ago #

    Hello Florence.

    it does not have a single.php file. It does have a page.php file so im assuming that is what it is using to display the post.

    After placing code into index.php i have got the video to display in the featured image section but not in the page itself. I am removing that code though as it is slowing the site down to a halt.

    is the code that needs modifying in page.php the same code as single.php? or would it be different?

  12. Jonathancairns
    Member
    Posted 1 year ago #

    from what i can see after exploring the code for the Hatch theme. it is coded different from other themes that people are using.

    Its frustrating as i am not familiar with coding and im getting the feeling that i am doing more harm than good

  13. Florence
    Member
    Posted 1 year ago #

    Well, just back-up your site and play with the code. If you screw it up, just replace the file and try again. In my experience that's the best way to learn.

    Compare the source code of you published pages to that of your posts. Also, look through the files to see if they maybe named the post template something different. Probably not though.

    If the page template is used for the posts as well, then you'll have to edit that.

    I had the same problem as you did. You have to find with which ID your theme calls the featured image. It's different for every theme. In my case it was 'post-thumb'

    Once you have that, look to the previous page of this thread for a reply by Mike Bikkel. He explained to me how you can turn the original featured image function into a conditional funtion which calls the featured video if it is there. Replace 'post-thumb' with whatever your theme's featured image ID is.

  14. Jonathancairns
    Member
    Posted 1 year ago #

    Thank-You Florence

    I'll give that a try

  15. Florence
    Member
    Posted 1 year ago #

    Good luck!

  16. Jonathancairns
    Member
    Posted 1 year ago #

    no luck unfortunately

    if in the event that a theme does not have a single.php file from what i recall of hierarchy it prioritises index.php correct?

    i have searched index.php, post.php and page.php but no luck with the Hatch theme. its the theme that i need to use so if anyone could provide advice it would be greatly appreciated

    http://wordpress.org/extend/themes/hatch

  17. Florence
    Member
    Posted 1 year ago #

    If you want I could take a look at your code. You'd have to create a temporary account for me. I'm not an expert or anything, but I can try..

  18. Jonathancairns
    Member
    Posted 1 year ago #

    Hi Florence

    Thank you for your kind offer, however atm i am working on a local server through MAMP.

    I have not made changes to the hatch theme so if you could please take a look at that it would be a great help.

    Many thanks Jonathan

  19. Jonathancairns
    Member
    Posted 1 year ago #

    i have discovered that the Hatch theme uses 'get-the-image' in post.php

    the following code seem promising

    <div class="post-content">
    
    							<?php if ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'link_to_post' => false, 'image_class' => 'featured', 'attachment' => false, 'width' => 640, 'height' => 360, 'default_image' => get_template_directory_uri() . '/images/single_image_placeholder.png' ) ); ?>
    							<div class="post-aside">

    does anyone recognise this code? it looks like it is referring to featured image

  20. Florence
    Member
    Posted 1 year ago #

    If you've got a post.php that's probably the equivalent of single.php. Can you post the full code that pulls the featured image?

  21. Jonathancairns
    Member
    Posted 1 year ago #

    Hello Florence

    im not sure which part of the code specifically deals with the Featured image as one part seems to lead into the other so i posted all of post.php

    <?php
    /**
     * Post Template
     *
     * This is the default post template.  It is used when a more specific template can't be found to display
     * singular views of the 'post' post type.
     *
     * @package Hatch
     * @subpackage Template
     */
    
    get_header(); // Loads the header.php template. ?>
    
    	<?php do_atomic( 'before_content' ); // hatch_before_content ?>
    
    	<div id="content">
    
    		<?php do_atomic( 'open_content' ); // hatch_open_content ?>
    
    		<div class="hfeed">
    
    			<?php if ( have_posts() ) : ?>
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php do_atomic( 'before_entry' ); // hatch_before_entry ?>
    
    					<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
    
    						<?php do_atomic( 'open_entry' ); // hatch_open_entry ?>
    
    						<div class="post-content">
    							<?php if ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'link_to_post' => false, 'image_class' => 'featured', 'attachment' => false, 'width' => 640, 'height' => 360, 'default_image' => get_template_directory_uri() . '/images/single_image_placeholder.png' ) ); ?>
    							<?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'));
    							   }
    							}
    							?>
    
    							<div class="post-aside">								
    
    								<?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?>
    
    								<?php echo apply_atomic_shortcode( 'byline_date', '<div class="byline byline-date">' . __( '[entry-published before="Date: "]', 'hatch' ) . '</div>' ); ?>
    
    								<?php echo apply_atomic_shortcode( 'byline_author', '<div class="byline byline-author">' . __( '[entry-author before="Author: "]', 'hatch' ) . '</div>' ); ?>
    
    								<?php echo apply_atomic_shortcode( 'byline_category', '<div class="byline byline-ategory">' . __( 'Category: [entry-terms taxonomy="category"]', 'hatch' ) . '</div>' ); ?>
    
    								<?php echo apply_atomic_shortcode( 'entry_meta', '<div class="entry-meta">' . __( '[entry-terms taxonomy="post_tag" before="Tags: "]', 'hatch' ) . '</div>' ); ?>
    
    								<?php echo apply_atomic_shortcode( 'byline_edit', '<div class="byline byline-edit">' . __( '[entry-edit-link]', 'hatch' ) . '</div>' ); ?>
    
    								<?php get_template_part( 'loop-nav' ); // Loads the loop-nav.php template. ?>
    
    							</div>
    
    							<div class="entry-content">
    								<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'hatch' ) ); ?>
    								<?php wp_link_pages( array( 'before' => '<p class="page-links">' . __( 'Pages:', 'hatch' ), 'after' => '</p>' ) ); ?>
    							</div><!-- .entry-content -->
    
    							<?php do_atomic( 'close_entry' ); // hatch_close_entry ?>
    
    						</div><!-- .post-content -->
    
    					</div><!-- .hentry -->
    
    					<?php do_atomic( 'after_entry' ); // hatch_after_entry ?>
    
    					<?php get_sidebar( 'after-singular' ); // Loads the sidebar-after-singular.php template. ?>
    
    					<?php do_atomic( 'after_singular' ); // hatch_after_singular ?>
    
    					<?php comments_template( '/comments.php', true ); // Loads the comments.php template. ?>
    
    				<?php endwhile; ?>
    
    			<?php endif; ?>
    
    		</div><!-- .hfeed -->
    
    		<?php do_atomic( 'close_content' ); // hatch_close_content ?>
    
    	</div><!-- #content -->
    
    	<?php do_atomic( 'after_content' ); // hatch_after_content ?>
    
    <?php get_footer(); // Loads the footer.php template. ?>

    Im trying to work out wether or not to delete the part of 'get-the-image'. when i delete it does not seem to cause compatibility issues.

    i still cannot get the video to display in the featured image

  22. Florence
    Member
    Posted 1 year ago #

    Try this.

    Replace

    ?php if ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'link_to_post' => false, 'image_class' => 'featured', 'attachment' => false, 'width' => 640, 'height' => 360, 'default_image' => get_template_directory_uri() . '/images/single_image_placeholder.png' ) ); ?>
    							<?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'));
    							   }
    							}
    							?>

    with

    <?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 ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'link_to_post' => false, 'image_class' => 'featured', 'attachment' => false, 'width' => 640, 'height' => 360, 'default_image' => get_template_directory_uri() . '/images/single_image_placeholder.png' ) );
       }
    }
    ?>
  23. Jonathancairns
    Member
    Posted 1 year ago #

    Hello Florence

    Thank you for your help, but that alteration to the code collapses the entire post. It does not display the video as the featured image and renders the post and all of my posts inaccessible. the pages are accessible so that good.

    i tried swaping the code around to:

    <div class="post-content">
    							<?php
    							   if ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'link_to_post' => false, 'image_class' => 'featured', 'attachment' => false, 'width' => 640, 'height' => 360, 'default_image' => get_template_directory_uri() . '/images/single_image_placeholder.png' ) );
    							}else{
    							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);

    but no luck. did not display video as featured image and the post was inaccessible

    with this code the post was accessible however the video does not display as featured image.

    <div class="post-content">
    							<?php if ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'link_to_post' => false, 'image_class' => 'featured', 'attachment' => false, 'width' => 640, 'height' => 360, 'default_image' => get_template_directory_uri() . '/images/single_image_placeholder.png' ) ); ?>
    							<?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'));
    							   }
    							}
    							?>

    it seems that the part with get the image has to be the first thing for the code to process. Maybe changing it to display video if there is not featured image. although thats what the plugin is meant to do. Ill admit i am at a loss of how to proceed

  24. Florence
    Member
    Posted 1 year ago #

    <?php if ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'link_to_post' => false, 'image_class' => 'featured', 'attachment' => false, 'width' => 640, 'height' => 360, 'default_image' => get_template_directory_uri() . '/images/single_image_placeholder.png' ) ); ?>
    Is the code that fetches your featured image.

    You need to combine it with

    <?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{

    For me it was

    <?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'));
       }
    }
    ?>

    because the function that got my featured image was 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')); ?>

    If that didn't work I'm out of ideas. Sorry! I'm pretty new to php coding myself. You need Mike Bikkel :)

    You could try posting these codes in another forum...

  25. Jonathancairns
    Member
    Posted 1 year ago #

    ok i tried something and it seems to have sort of worked. this is the code i entered into post.php

    <div class="post-content">
    							<?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'));
    							   }
    							}
    							?>

    its Mikkel's code. i tried it before but it did not work. i must have put it in the wrong place.

    the only thing i need to work is to get the video to appear as a featured image on the homepage

  26. Florence
    Member
    Posted 1 year ago #

    No the second part is what's wrong. That's my code and it works specifically for my theme. You need to replace the second part with the code that fetches the featured image for your theme. That's what I posted earlier.

  27. nemanja.radevic
    Member
    Posted 1 year ago #

    Guys this works perfectly the only thing i would like to add here the video to open with prettyphoto in a popup

    so this means i need a video have a thumbnail that is small for example 100x100 and when you click on it, it should open with prettyphoto and play

    Does anyone knows how to do this?

    until now i got this and it s working but without popup

    <?php
    if(get_post_meta(get_the_ID(), "_related-video", true) != ''){
    //THIS PART HERE SHOULD HAVE
    //<a>"><?PHP THE THUMB OF THE VIDEO ?></a>
        echo get_post_meta(get_the_ID(), "_related-video", true);
    
    }else{ ?>
    //FROM HERE I SET MORE THAN 1 FEATURED IMAGES ON MY SITE AND I AM USING //TIMTHUMB TO MAKE EM SMALLER AND THEN OPEN THE ACTUAL SIZE WITH //PRETTYPHOTO
    		<div id="image-right-1">
    			<a>" rel="prettyPhoto">	
    
    <img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo kd_mfi_get_featured_image_url( 'featured-image-2', 'page' ); ?>&h=135&w=178&zc=1" alt="" />
    <?php } ?></a>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still - use the pastebin. As it stands, your code has been permanently damaged/corrupted by the forum's parser.]

  28. Jonathancairns
    Member
    Posted 1 year ago #

    @nemanja.radevic

    that is a good idea. unfortunately trying to get this plugin to work with my theme is causing everything to go pear shaped so i will be unable to help you with the code

  29. souwar
    Member
    Posted 1 year ago #

    can please someone help me with this issue i can see the featured video box when editing pages but it's not there for Posts, i know that there is a reply for this matter but i don't know how to start and what is the final version of the solution :(

  30. souwar
    Member
    Posted 1 year ago #

    Floortjahh you are able to help please

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic