WordPress.org

Ready to get started?Download WordPress

Forums

Post Thumbnails Not Working? (6 posts)

  1. KeenanPayne
    Member
    Posted 2 years ago #

    Hello,

    I am having trouble with a theme that I have designed and developed myself.

    I am using post thumbnails on the homepage and single posts, and I need the images to be scaled correctly so they don't look crunched or bad. So here's what I have in my index.php file:

    <?php the_post_thumbnail( 'homepage-thumb', array() ); ?>

    And here's what I have in my functions.php file:

    if (function_exists('add_theme_support')) {
        add_theme_support('post-thumbnails');
    }
    add_image_size( 'homepage-thumb', 176, 99 );

    But whenever I use the above code, you can see how the images look at http://staging.slackrmedia.com/wp/?themedemo=theme. They are uneven in width and that's not what I wanted.

    Can anybody help me out? I would really appreciate it!

    Thanks,
    Keenan

  2. potentweb
    Member
    Posted 2 years ago #

    Change add_image_size() to
    add_image_size( 'homepage-thumb', 176, 99, true) the last part true tells it to crop it to exactly that size.

    Brian

  3. KeenanPayne
    Member
    Posted 2 years ago #

    Thanks potentweb, except for my code now looks like this:

    if (function_exists('add_theme_support')) {
        add_theme_support('post-thumbnails');
    }
    add_image_size( 'homepage-thumb', 176, 99, true);

    But the result is no different. I just made a new post to test it but the image width wasn't the same. All of the heights are 99, but the widths change.

    http://staging.slackrmedia.com/wp/?themedemo=theme

  4. potentweb
    Member
    Posted 2 years ago #

    Hi, you have to regenerate the thumbnails, by installing the thumbnail regeneration plugin. After you add anything new to the add_image_size() function, you have to regenerate the thumbs, it does not automatically regenerate it.

    Found this on the web with examples of how the add_image_size() function works with picture examples.

    http://techblog.willshouse.com/2012/02/15/understanding-wordpress-add_image_size-with-examples/

  5. KeenanPayne
    Member
    Posted 2 years ago #

    Thank you very much for that! I completely forgot about regenerating my thumbnails, but that fixed the problem!

  6. potentweb
    Member
    Posted 2 years ago #

    No problem. Good luck!

    Brian

Topic Closed

This topic has been closed to new replies.

About this Topic