Hi!
If the original image has a landscape proportion and the medium size is of scale type (to a max width or a max height), then the final medium image will be generated by resizing the original image to it’s largest size (in this case the width for a portrait) until it reaches 300px and the height will be proportional.
If you want the medium image size to be of exactly 300x300px, then you have to change the way the images sizes are configured, to make the medium of crop type, not scale (at least this is how I understand the image sizes are configured in your site).
Another note, the crop options for the images are available only for image sizes configured to crop, not for scale type (that is why you see the crop options only for some of the images).
Let me know if this helps.
So is there a way to get medium and large sizes cropped just like with thumb size?
The answer is yes, the default crop settings to be applied general to an image size can be set individually for each image size of crop type (not scale) and also changed for each cropped image.
I don’t see any cropping options for medium and large sizes. Only for thumbnail size. Could you give me more details about this?
There are two types of image sizes: scale (resize) and crop. By default, WP sets the medium and large as scale type and only the thumbnail as crop type.
If you want to force the medium or large to a crop type, then you have to make changes programmatically in your theme or with a plugin. Does this answer your question?
I’m not completely sure what you mean with programmatic changes, but this is how I coded the image sizes in my theme:
add_image_size( 'large', 620, '', true); // Large Thumbnail
add_image_size( 'medium', 300, 300, true); // Medium Thumbnail
add_image_size( 'thumbnail', 160, 160, true); // Thumbnail
Is there anything else I should do so your plugin allows the cropping feature for medium and large sizes? Because, as you can see, the medium size is already being cropped by default, but when I activate your plugin, it doesn’t work anymore, WP will just resize them without cropping them.
The codex mentions : http://codex.ww.wp.xz.cn/User:Esmi/add_image_size%28%29
add_image_size( $name, $width = 0, $height = 0, $crop = FALSE)
My understanding from the sample you gave is that when you put the crop option, you must specify the width and height of the crop, your height is not mentioned.
add_image_size( ‘large’, 620, ”, true); // Large Thumbnail
However, the image size you set in the theme can be override in another place. This plugin does not change your image sizes.
It might be helpful if you can provide a screenshot of the entire set of settings you see for the plugin.
Also, please check if the image sizes changes are added with a similar hook like described here https://developer.ww.wp.xz.cn/reference/functions/add_image_size/.
I tried everything you suggested, but it’s still not working. Does the medium and large sizes allow you to crop them?
Something I discovered is that it works fine for custom image sizes.
Here goes my config:
IMAGE
K, and where are you setting the medium and large to be of crop type ?
That’s the problem. I don’t have them, and I don’t know why :S Everything I can see is what I showed you in the picture above.
But if you do a global search in your project can you find the lines where you think the medium and large are set to be of crop type ?
You have to make sure that you have the explicit setup for these under a proper hook, use the “after_setup_theme” action hook.
Yes, its setup looks just like that in my functions.php file:
function my_thumb_sizes() {
add_image_size( 'large', 620, '', array( 'center', 'center' ) ); // Large Thumbnail
add_image_size( 'medium', 300, 300, array( 'center', 'center' ) ); // Medium Thumbnail
add_image_size( 'thumbnail', 160, 160, true); // Thumbnail
add_image_size( 'custom-size-1', 320, 160, true); // Custom size 1
add_image_size( 'custom-size-2', 620, 320, true); // Custom size 2
}
add_action( 'after_setup_theme', 'my_thumb_sizes' );
Have you tried to set the large and medium with the crop option as bool (like what you did for the thumbnail) ?
Yes, I’ve tried all that. Even in different installations of WP.
Could you show me a screen capture of your configuration page? Just to be sure that I’m the one having the problem.