Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've set up a bunch of additional image sizes in my functions.php theme file, with the crop parameter set to true. However, the images are resized but not cropped.

    if (function_exists('add_image_size')) {
        add_image_size('frontpage_a-la-une_thumb', 400, 215, true);
        add_image_size('single_thumb', 320, 9999, false);
        add_image_size('category_a-la-une_thumb', 280, 215, true);

        add_image_size('xxs-square-thumb', 60, 60, true);
        add_image_size('xs-square-thumb', 70, 70, true);
        add_image_size('s-square-thumb', 98, 98, true);
        add_image_size('square-thumb', 130, 130, true);
        add_image_size('l-square-thumb', 198, 198, true);

        add_image_size('landscape-thumb', 150, 98, true);
        add_image_size('portrait-thumb', 98, 145, true);
    }

The GD library is installed, so is imageMagick, but no dice.

What am i missing?

UPDATE: Problem arises with images that are smaller than the set image size: i was expecting WP to create image versions by scaling them up, but it doesn't. So, my bad, sorry for getting that point wrong.

share|improve this question
1  
Could you add specific example with actual numbers? Like "I upload image of these dimensions and expect such size to be that, but instead it's...". There is quite a few lines of math going on to calculate resize and there are kinks in it that are much easier to catch when dealing with real numbers. –  Rarst Nov 1 '11 at 12:24
    
You're right: i did some tests carefully noting down image sizes and verifying what was done. Wrong ok for large images, doesn't work for images smaller than the set size, and my assumption is wrong. See Question update. –  pixeline Nov 3 '11 at 10:24

3 Answers 3

up vote 3 down vote accepted

Currently, WordPress core image handling/thumbnail creation does not perform zoom-crop. If you need an intermediate image size to be created explicitly, you will need to ensure that you upload an image with equal or larger dimensions as the intermediate image size.

share|improve this answer
    
zoom-cropping. That's exactly the term describing what i was looking for. I'll look into an existing plugin, or possibly develop one that does that. –  pixeline Nov 4 '11 at 13:47

This might seem ridiculous, but have you tried 1 instead of true?

Like so: add_image_size('custom-size', 116, 151, 1 );

Of course, you'll need to regenerate your images again using the Regenerate Thumbnails plugin once you've updated your functions.php file.

share|improve this answer
    
The documentation explicitly says it should be "true" or "false". codex.wordpress.org/Function_Reference/add_image_size –  pixeline Nov 1 '11 at 12:12
    
I'm aware of that. But I've used 1 and 0 in every theme I've built and it works flawlessly. –  Dominic Nov 1 '11 at 12:55
    
Does cropping only fail on your custom image sizes? Under Settings > Media what happens if you set "crop thumbnails to exact dimensions" and rebuild your images? –  Dominic Nov 1 '11 at 21:22

You'll need to regenerate the thumbnails for existing images. I use this plugin: http://wordpress.org/extend/plugins/regenerate-thumbnails/

If your new images aren't being cropped correctly then you have another issue.

share|improve this answer
    
i already use that plugin. It's another issue, probably related to the server configuration. But what exactly... –  pixeline Nov 1 '11 at 8:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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