WordPress.org

Ready to get started?Download WordPress

Forums

How to force crop to exact dimensions for medium size image resize? (5 posts)

  1. catsandbeer
    Member
    Posted 6 years ago #

    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?

    Thanks

  2. volanStudio
    Member
    Posted 5 years ago #

    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:

    $crop=true;

    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...

  3. pad
    Member
    Posted 5 years ago #

    Where do I add $crop=true;

    Awaiting this wonderful plugin!

  4. ray1618
    Member
    Posted 5 years ago #

    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.

  5. Aesqe
    Member
    Posted 5 years ago #

    please take a look at this topic:

    http://wordpress.org/support/topic/238007

Topic Closed

This topic has been closed to new replies.

About this Topic