0

I want include function to resize featured image to 80x80, im add this code in my function.php

add_theme_support('post-thumbnails');
set_post_thumbnail_size(80, 80); 

But is not work very good, images is not resized, looks like scaled to 80x65 or something.. i need exactly 80x80 on every images uploaded...

  • Did you upload images after adding these lines or before it? – Krzysiek Dróżdż Nov 17 '13 at 14:34
  • Im edit function.php and after that im try upload images – Milan Milosevic Nov 17 '13 at 14:50
  • To apply changed thumbnail sizes to already uploaded images you have to regenerate the thumbnails, for example with the plugin Regenerate Thumbnails – Nicolai Nov 17 '13 at 15:04
2

I believe you need to pass the third $crop parameter to set_post_thumbnail_size. In other words...

set_post_thumbnail_size(80, 80, true); 

That third parameter enables a "hard-crop" mode. From the Codex:

Set the default Post Thumbnail size by cropping the image (either from the sides, or from the top and bottom):

Without that argument, or with it set to false, you get a resize without distortion-- ie. as close as possible to your dimensions. Also from the Codex:

Set the default Post Thumbnail size by resizing the image proportionally (that is, without distorting it):

0

You too, can add a Thumbnail size using add_image_size().

<?php add_image_size( 'email', 300, 200, true ); ?>

Then you can user from your theme:

<?php
if(has_post_thumbnail()) {
    the_post_thumbnail('email');
}
?>

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.