WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
With Photon enabled, post-thumbnail disappears on blog index page (10 posts)

  1. Dave P.
    Member
    Posted 1 year ago #

    I created some custom thumnail sizes in my functions.php using the following:

    /* Enable featured image */
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 650, 300, true );
    
    if ( function_exists( 'add_image_size' ) ) {
    	add_image_size( 'sidebar-thumb', 300, 150, true );
    	add_image_size( 'small-thumb', 125, 125, true );
    	add_image_size( 'home-thumb', 300, 182, true );
    }

    I then call the thumbnail on the blog index page using the following:

    <?php
    				$id = get_post_thumbnail_id();
    				$image_attributes = wp_get_attachment_image_src( $id ); // returns an array
    				if ( has_post_thumbnail() ) {
    					if ($image_attributes[1] > 649) {
    						the_post_thumbnail();
    					}
    				}
    			?>

    It works fine, but as soon as I enable Photon, the images disappear. When I disable it, they come back. Any ideas how I can fix this?

    http://wordpress.org/extend/plugins/jetpack/

  2. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    I noticed that you use wp_get_attachment_image_src to get some information about your image. That's probably what's causing the issue here.
    You can read more about this issue here, and you could check this thread for a solution.

    Let me know if this helps.

  3. Dave P.
    Member
    Posted 1 year ago #

    Thanks for the that, the solution thread is a bit over my head. One problem I see that is that I changed my code to the following on index.php:

    <?php
    				if ( has_post_thumbnail() ) {
    						the_post_thumbnail();
    				}
    			?>

    And it still would not show up when I activate Photon...With no references to wp_get_attachment_image_src, wouldn't that mean something else is causing a problem?

  4. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    That is weird. What happens when you switch to a different theme, like Twenty Twelve? Are Featured Images displayed properly?

  5. Dave P.
    Member
    Posted 1 year ago #

    I switched it over to Twenty Twelve and they do appear. I must have not uploaded the file before or something, sorry about that.

    So going back to the original issue, as mentioned that solution thread is a bit over my head. If I only want a featured image to show up that is over 649px wide, is there a way I can do that while still using Photon?

  6. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    If I only want a featured image to show up that is over 649px wide, is there a way I can do that while still using Photon?

    You could create a new thumbnail size, like so:

    add_image_size( 'big-thumb', 649, 9999 ); // Big thumbnails!

    And then, you can call that post thumbnail in your template:

    if ( has_post_thumbnail() ) {
    	the_post_thumbnail( 'big-thumb' );
    }

    To regenerate all thumbnails and create these new images, you can use this plugin:
    http://wordpress.org/extend/plugins/regenerate-thumbnails/

  7. Dave P.
    Member
    Posted 1 year ago #

    My problem is that we have a bunch of old posts with thumbnails that are 120x80 that we want to ignore. So we were using the if function before so it only displays the image if it's over 649px (see first post). Is there any way to do something similar like this while using Photon?

  8. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    If the original image isn't large enough to create a "big-thumb" post thumbnail, no image should appear in the post.

    Could you test it on your site, and let me know if it helps?

  9. Dave P.
    Member
    Posted 1 year ago #

    I tried to do this (on a local test site) but it was still showing the thumbnail when it was 125x80. Just to confirm, my functions.php has:

    /* Enable featured image */
    add_theme_support( 'post-thumbnails' ); 
    
    if ( function_exists( 'add_image_size' ) ) {
    	add_image_size( 'big-thumb', 650, 300, true );
    }

    And I'm calling the post thumbnail this way:

    <?php
    			if ( has_post_thumbnail() ) {
    					the_post_thumbnail( 'big-thumb' );
    				}
    			?>
  10. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    What happens when you regenerate the thumbnails thanks to this plugin? Do you still see small thumbnails?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic