No matter what I do - I can't get the hard cropping mode in the_post_thumbnail to work.

Here's what I have:

add_image_size( 'Blog', 300, 300, true ); 

I've also tried:

set_post_thumbnail_size( 300, 300, true );

I've tried uploading new images, and using the "Regenerate Thumbnails" plugin, but still no luck. It completely ignores the "true", and acts as if it's "false". For example, instead of the image being 300x300, it'll be 300x238 or something.

Has anyone else experienced this? My GD Library is enabled..

Thanks for any input anyone can offer =)

  • 2
    Your code looks fine. I've pulled my hair out on this before and the issue I had was because the images my client was uploading were smaller than the crop size and while it would scale up the larger dimension it wouldn't scale up both. That was a few versions ago but might be something to check.
    – patnz
    Dec 8, 2011 at 3:22
  • Upload an image larger than 300x300 and it should work.
    – Chris_O
    Dec 8, 2011 at 5:24
  • Thanks for your comments. Unfortunately, I've tried to upload large images to be resized, and still I'm having no luck. For example, I changed my code to this: add_image_size( 'Blog', 200, 200, true ); The image I uploaded (freshly) is 359x500. The end result, is the image being 143x200. I have no idea what else to try lol Again, I appreciate your comments!
    – Tom
    Dec 8, 2011 at 19:41
  • Most likely a server issue -> check my answer below. Feb 17, 2012 at 9:33
  • Targeting the edit I just approved: Please add solutions as answer. You can mark them as solution (green check mark below voting arrows) two days later.
    – kaiser
    Jul 26, 2012 at 1:11

8 Answers 8


A lot of the time the reason it isn't working because you haven't regenerated the thumbnails for all your images.

If you have changed the dimensions of your images you will need to regenerate your thumbnails using this plugin: http://wordpress.org/extend/plugins/regenerate-thumbnails/

  • 1
    I don't think you can do it from the default media library, can you? I had to use the "Regenerate Thumbnails" plugin.
    – Simon East
    Sep 15, 2014 at 9:17
  • 1
    Yep, that's true. I forgot to mention that a couple years ago in my more novice days :P Edited my answer.
    – bryceadams
    Sep 15, 2014 at 12:09

I would say that you might not have the GD libraries installed on your server. Without this, you will only get the file uploads and no image crops.

First, do a sanity check by calling phpinfo() to see if GD is installed.

GD Installation on Linux

If you have shell access, simply type this command:

sudo apt-get install php5-gd

You'll need to restart the server after installing GD

Here's the command to reboot Apache:

/etc/init.d/apache2 restart

Shared Hosting

If you're on a shared box, you'll need to contact your host and have them install it on your server.

One Last Thing

Does your theme have thumbnail support?

  • 1
    Thanks a lot for answering, Brian =) I have confimed that the GD Library is installed on my server (I'm using WAMP) - I've also encountered the same thing happening on my server and others. The issue has me stumped, I'm stuck thinking it's something I'm doing but everything looks as it should. Any other ideas? Thanks a lot.
    – Tom
    Feb 19, 2012 at 3:45
  • @Tom Check out the latest edit. :) Feb 19, 2012 at 11:53
  • 1
    Thanks for the follow up. I do have thumbnails enabled, as I can choose the featured image, and it shows up, it just doesn't hard crop to the dimensions I tell it to. Could it be conflicting with something else in my theme? I have TimThumb doing the job for now, but would love to use WordPress functions wherever possible.. Thanks again =)
    – Tom
    Feb 20, 2012 at 17:53
  • This was the answer I was looking for. I knew I had to install some package, and was just looking for which one... thanks
    – Orabîg
    Jan 14, 2013 at 0:05

I've actually finally fixed this issue.

It seems that the hard-cropping works if you set the image size inside a function that is hooked into the "after_setup_theme" hook.

So, the below would work:

function add_custom_sizes() {
    add_image_size( 'portfolio-thumb', 243, 163, true );
    add_image_size( 'portfolio-image', 1074, 725, true );
    add_image_size( 'available-homes', 500, 279, true );
    add_image_size( 'idea-thumb', 146, 141, true );

This will allow you to get actual hard cropped images using the sizes specified using the_post_thumbnail().

Hope this helps someone else as well.

  • 1
    tried everything including this, still didn't work Oct 3, 2018 at 3:44
  • 1
    This also does not work for me.
    – Lars SG
    Feb 11, 2021 at 5:30

Instead of defining the post thumbnail size as blog why not just set the post thumbnail explicitly in the template where you want it to show up...

the_post_thumbnail($post->ID, array(300,300, true));

I've just had this same issue and the answer for me was regenerating thumbnails as bryceadams suggested (I don't have enough points to vote for his response unfortunately).

Caveat: The images must be stored locally not remotely. Presumably no thumbnails are generated for remote images.


In my case, this issue was caused by filer permissions on the images. I had copied the images from one server to another, forgetting to change the ownership. When new image sizes were set, and I regenerated them, the old images weren't overwritten as they should have been.

To fix this I connected to my server with SSH, navigated to the wp-content/uploads folder and reset the ownership of all the images there. e.g.

chown -R {web user}:{group} .

Hope that helps someone.


You'll never have a hard-cropped image other than the default sizes. You'll not get this answer in WP forums, or if you do, they'll show you a carrot for weeks until you get anxious and get blocked or they fixed it silently.

The hard-cropped images are only for

  • Thumbnail
  • All other sizes EXCEPT thumbnail AND YOUR CUSTOM SIZES

Things that are not possible are NEVER shown in the front end or tried to be covered up in forums as much as possible (our free .org project is their .com product) even if the above options got you pulling your hair for months.

The second option should read "ALL OTHER SIZES EXCEPT YOURS"

I'm developing a plugin for that, and an extra magic. I'll get it done soon, but I'll need some help to publish it in the plugins library since I've been banned! hehe (for helping others with un-reported (or ignored) bugs)


I had the same issue and installed a plugin that allows to regenerate one/some/all of your images. This is the plugin: [http://wordpress.org/plugins/regenerate-thumbnails/]

I did not find the way of doing it from the WP admin UI except if you delete and upload the image again.

Another way of doing it, if you do not want to use a plugin, would be to do it with PHP functions

function wp_regenerate() {
include( ABSPATH . 'wp-admin/includes/image.php' );
wp_generate_attachment_metadata( $thumbnail_id, $absolute_path_to_image ); }

add_action('after_setup_theme', 'wp_regenerate');

where $thumbnail_id and $absolute_path_to_image have to be set with the values you want.

Thanks to @briceadams and @adriaticiq. I cannot yet vote you but I will as soon as I am allowed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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