Support » Plugins » How to force crop to exact dimensions for medium size image resize?

  • Under dashboard > settings > miscellaneous settings > image sizes one can specify the width and height of thumbnails generated automatically by the media library and tick a checkbox to “Crop thumbnail to exact dimensions (normally thumbnails are proportional)”

    you can also specify the max width and max height of the ‘medium size’ images similarly autogenerated, but you can’t check a box to force the cropping in the same way.

    I’m inside wp-includes/media.php trying to hack this change, to force the cropping of the resized ‘medium size’ version of an uploaded image to the max width and max height specified in this part of the admin page but am not getting it to work – has anyone done this and can let me know how or could take a quick look at the file and see if s/he can figure out how to do it?


Viewing 4 replies - 1 through 4 (of 4 total)
  • I came across this today. I came up with a filthy hack fix to force crop both thumb size and medium size images.
    This is for 2.5.2:
    Just get into wp-includes/media.php and go to line 148 and add the following code as the first line in the function image_resize_dimensions:


    That’ll force the issue of the crop. I am about to write a plugin that’ll set up the ability to just check a box in the settings menu of the admin section, but until then a filthy hack…

    Where do I add $crop=true;

    Awaiting this wonderful plugin!

    Thank you for your filthy hack :).

    open the file wp-includes/media.php
    and search for function image_resize_dimensions: @ line 148
    add $crop=true; on the white line under this like Volan said.

    please take a look at this topic:

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to force crop to exact dimensions for medium size image resize?’ is closed to new replies.