Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I set 2 crop sizes in the functions.php file.

// Setup Post Thumbnails
// -----------------------------------------------
add_theme_support('post-thumbnails');
add_image_size('imagePost-thumb', 970, 9999,false);
add_image_size('better-thumb', 200, 9999, false);

Then in the appropriate loops we pull one of the thumbnails based on post type.

<?php if ( has_post_thumbnail() ): ?>
     <?php $size = (get_post_type() == 'imagepost') ? 'imagePost-thumb' : 'better-thumb'; ?>
     <?php get_better_post_thumbnail($size); ?>
<?php endif; ?>

Get better_post_thumbnail() is a function I wrote to get the image and the caption. In it I call the the_post_thumbnail to display the image. Here is that function.

function get_better_post_thumbnail($size) {
    $thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
    echo '<div class="thumbnail">';
    echo '<a href="' . $thumbnail_src[0] .'">';
      the_post_thumbnail($size);
    echo '</a>';
    if( get_post( get_post_thumbnail_id() )->post_excerpt )
        echo '<p class="wp-caption-text">' . get_post( get_post_thumbnail_id() )->post_excerpt . '</p>';
    echo '</div>';
}

This works great on my test server. The only problem is when I push it to the live server, the crops don't work. The images appear as the the correct size because our theme styles them but they are loading at full size.

Per @MathSmith's suggestion I checked the live server to see if the different image sizes were being created and they are NOT. The test server has all the different files sizes while the live server only has the full size.

We don't want to load a 1024x1024 picture when it never is displayed larger than 400x400. Of course I could crop the pictures by hand, but my bloggers are all specialists who have a harder time with 'technology' and need it to happen automatically, as it should.

Our dev and live setups are identical except for the w3 Total Cache plugin on the live server, but I disabled it and tested the images, with the same results.

Any ideas?

share|improve this question
    
Just to be sure: did you upload the images in question AFTER you added the custom sizes? add_image_size doesn't retroactively (or "real time") crop anything. Also, please post the code for your get_better_post_thumbnail() function. –  MathSmath Jun 13 '12 at 21:08
    
Yes I added the images after the custom sizes. I also tried regenerating the thumbnails. I also tested it by changing the crop settings and then making a new post and it worked on the test server but not the live one.I also added the code for get_better_post_thumbnail() function. Thanks @MathSmath –  Joshua Dance Jun 13 '12 at 21:21
    
One more check--can you verify that the image files are actually being created on your live server? In other words, is the problem that the files are not being created in the first place, or that the_post_thumbnail() doesn't retrieve them? –  MathSmath Jun 13 '12 at 21:45
    
WOW! The live server is NOT making the custom image sizes. The test server has apple-150x150.png, apple-390x390.png etc but the live server only has apple.png –  Joshua Dance Jun 13 '12 at 21:56
1  
Yes, greyed out means they don't exist. Disable your plugins and revert to the default theme, does the problem still occur? If so it might be a server issue. If not slowly add each plugin and then the theme to see what's preventing it. –  Wyck Jun 13 '12 at 22:11

1 Answer 1

Figured it out! Our live server was missing the GD Image Library. For some reason it was not included in the package we used to instance our server.

I found the tip about the GD lib in this thread from the Wordpress support forum. It was three years old, but pointed to the missing library.

We never noticed the fact that the thumbnail size selectors were greyed out because we thought we were taking care of sizing using the Theme Function file.

Thanks @MathSmith and @Wyck

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.