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 recently launched a new theme and regenerated all the thumbnails with AJAX Rebuild. All of these custom image sizes are defined in my functions.php as well as the individual template files in which they are used. When I go and view source code my site, I don't see the new image sized appended to the end of the file name. I do however see the class name on the image that WordPress assigns is the new image size. I don't get what's going on!

functions.php

if (!function_exists('mytheme_setup')) {
    function mytheme_setup() {
        add_theme_support( 'post-thumbnails' );
        add_image_size('homepage', 704, 396, true);
        add_image_size('articles', 1174, 660, true);
        add_image_size('in-post', 568, 320, true);
        add_image_size('featured-post', 1280, 683, true);
   }
}

add_action( 'after_setup_theme', 'mytheme_setup' );

Example of how I call it:

<article id="post-<?php the_ID(); ?>" <?php post_class('post_content'); ?>>
    <div class="social-drawer"></div>
    <a href="<?php the_permalink(); ?>">
        <?php print_meta(); ?>
        <?php 
            if (has_post_thumbnail()) {
                the_post_thumbnail('in-post');
            } else { ?>
                <img src="<?php bloginfo('template_directory'); ?>/img/in-post-568x30-default.jpg" alt="All Features" />    
        <?php } ?>
    </a>
</article>

Update I believe I discovered the issue. I did all of my image resizing on my staging site and then copied the resized images on staging to my production site (where I am currently experiencing these issues.) I have no learned that the DB references these image attachments and because I did not generate the sizes on Production, WordPress is unable to find the proper reference in the DB.

share|improve this question
    
Provide a link to that plugin. Does your code work with any of the sized you added or is it limited to that in-post size? –  s_ha_dum Apr 3 '13 at 13:14
    
Based on WP's documentation (scroll to bottom and see Resources) these are the plugins they recommended -- I've tried both Ajax Rebuild and Regen. Thumbnails: codex.wordpress.org/Function_Reference/add_image_size –  Brian Apr 3 '13 at 13:16
    
It's not using any of the custom sizes I generated on any of my templates,just the normal default image. –  Brian Apr 3 '13 at 13:17
    
1) I am not questioning the viability of the plugins. I wanted an easy way to see the source. It is just polite for the asker to provide that convenience. 2) If you aren't using the new sizes, exactly what is the problem? Sorry, that last comment of yours is confusing. –  s_ha_dum Apr 3 '13 at 13:22
    
Hi, I updated the question with some further information –  Brian Apr 3 '13 at 14:07
add comment

1 Answer 1

The function.php:

if ( function_exists( 'add_theme_support' ) ) {
    add_theme_support( 'post-thumbnails' );
        set_post_thumbnail_size( 150, 150 ); // default Post Thumbnail dimensions   
}

if ( function_exists( 'add_image_size' ) ) { 
    add_image_size('homepage', 704, 396, true);
    add_image_size('articles', 1174, 660, true);
    add_image_size('in-post', 568, 320, true);
    add_image_size('featured-post', 1280, 683, true);
}

To make it appear in .php-file:

<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'in-post' ); } ?>

That would be my suggestion.

share|improve this answer
    
The OP is already using the_post_thumbnail( 'in-post' ); in the template files. –  s_ha_dum Apr 3 '13 at 13:20
    
I am aware, but I believe the code he's using in his function.php is wrong. It might not be, but it just looks strange to me. –  Frederick Andersen Apr 3 '13 at 13:21
    
Did you test that your code behave correctly and the OP's doesn't? The OP's code looks like it should work to me, and it appears to be nicely encapsulated into an override-able function as well. –  s_ha_dum Apr 3 '13 at 13:26
    
Hi, I updated the question with some further information. –  Brian Apr 3 '13 at 13:58
add comment

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.