• Dave P.

    (@callmedpit)


    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/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    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.

    Thread Starter Dave P.

    (@callmedpit)

    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?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

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

    Thread Starter Dave P.

    (@callmedpit)

    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?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    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/

    Thread Starter Dave P.

    (@callmedpit)

    My problem is that we have a bunch of old posts with thumbnails that are 120×80 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?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    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?

    Thread Starter Dave P.

    (@callmedpit)

    I tried to do this (on a local test site) but it was still showing the thumbnail when it was 125×80. 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' );
    				}
    			?>
    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

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

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘With Photon enabled, post-thumbnail disappears on blog index page’ is closed to new replies.