• Resolved Evan Herman

    (@eherman24)


    I am building a theme for the company I work for. I am having a little bit of a difficult time getting the custom thumbnail size working properly.

    I have set the custom thumbnail size in my functions.php file

    add_image_size( 'custom-blog-picture', 617, 999, true ); //617 pixels wide (and unlimited height)

    I want the image to be 617px wide (which is the full width of the content container) and 281px high, with the image cropped to those dimensions.

    I then call the custom thumbnail size in my theme template file like so:
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('custom-blog-picture'); ?></a>

    Note: The height and width of the image I am using is 620px x 388px.

    I set the featured image of the post, and refreshed the page and the image gets pulled on to the page with the size of 617px x 388px.

    I then tried to set the featured image size to a hard value:

    add_image_size( 'custom-blog-picture', 617, 281, true ); //617 pixels wide (and unlimited height)

    But the image then was set at a width 446px and a height of 281px. So now it seems like the width dictates what the height is going to be?

    But I’ve set the crop mode to be true. So why isn’t the image being cropped at 617×281 and displayed as such??

Viewing 4 replies - 1 through 4 (of 4 total)
  • After amending add_image_size, are you uploading a new image? The new settings will only apply to newly uploaded images. For older images, you need to use a regeneration plugin.

    I like: Force Regenerate Thumbnails

    Thread Starter Evan Herman

    (@eherman24)

    Thanks for the reply. I have been trying to reply to this thread, but each time I do I’m getting a “this thread is closed error”.

    I previously added a custom image size that was working with out a hic-up. I moved my second custom image size decleration above the previously declared one and it worked. (I needed to regenerate thumbnails, as you had suggested wpranger).

    I actually ended up using an image size decleration like this (and it works),

    add_image_size( 'custom-blog-picture', 999, 281, true ); //617 pixels wide (and unlimited height)

    I added a max-width:100% to the image inside of the content container, and all is working as anticipated. I don’t know why re-arranging my declarations would make that much of a difference, but it did.

    I have been trying to reply to this thread, but each time I do I’m getting a “this thread is closed error”.

    Hey Evan, your post was caught in the spam filter… happens sometimes :(.

    Thread Starter Evan Herman

    (@eherman24)

    ahh, I see.

    Thanks for the heads up Yogi!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Thumbnail Image Cropping?’ is closed to new replies.