0

I am trying to resize an image using either the following code:

add_image_size('poster-full', 450, 9999, false); OR add_image_size('poster-full', 450);

I need it to be resized widthwise, and height should be proportional. When, I go and Run the Regenerate Thumbnails Plugin, i see that the image is resized correctly. For both the above cases.

But, when I do the_post_thumbnail('poster-full'), The Orginal Image shows up, and not the resized one. I manually searched the directory. The resized Image exists.

3
  • 1
    does the same thing happen if you upload a new image that did not previously exist? – Milo Mar 14 '16 at 17:01
  • Yes. And also, other image sizes work fine. The problem is with this particular case only. – Rohitink Mar 14 '16 at 17:17
  • A thumbnail is only resized when the image is bigger as the set width and height. So if you set 1000x1000px and upload an 500x500px image the image still will be 500x500px. If you upload 500x2000px the image will resize to 500x1000px. – Jorin van Vilsteren Mar 14 '16 at 18:02
1

For this to work, you must have added the thumbnail support. You can use the following code in functions.php to add the support

add_theme_support( ‘post-thumbnails’ );
add_image_size('poster-full', 450, 9999, false);

and to display the image:

if ( has_post_thumbnail() ) {
 the_post_thumbnail("poster-full");
}else{
 echo "No thumbnail";
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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