I just submitted my first WordPress core patch today and have been receiving lots of positive feedback. It allows developers to set the crop position by specifying an array for the $crop parameter in the
add_image_size function (see the Trac ticket for more details). WordPress 3.3 is at beta 4 at the moment, so it won’t make it into the 3.3 release. Hopefully it will make it into 3.4 and we can all enjoy cropped images with proper positioning (especially screenshots).
If you’ve done a Google search for a solution to defining the image crop position, you will likely find several articles on how you can hack the WordPress core to change the crop position. Gross! Not only is it terrible practice to edit core WordPress files (#1 reason: makes upgrading a royal PITA), but this solution also changes the crop position for all your images. What if you want different crop positions for different image sizes? The following solution accomplishes this without hacking the core.
Copy and paste the following code into your theme’s functions.php file (or create an include file) and use the function
bt_add_image_size instead of
add_image_size. Once the patch is implemented in a core release you should be able to revert to using
add_image_size and remove the code you copied into functions.php. As a bonus, I’ve included code that properly rotates photos containing EXIF data indicating the photo should be rotated for viewing. If you need to regenerate your previously uploaded images, I recommend Alex’s Regenerate Thumbnails plugin.
Wouldn’t take much to make this into a plugin, but it’s not worth going through the whole process for me personally.
Get an email notice when I publish a new blog post
Prefer RSS? Subscribe to my news feed