How to Set Image Cropping Position in WordPress

image cropping

WordPress 3.9 was just released few weeks ago and as expected, there are lots of new great features added and some enhancements made to the existing features. WordPress has add_image_size() function that allows theme developer to register new image sizes to their theme. The function accepts for parameters - $name, $width, $height and $crop.

Prior to WordPress 3.9, the crop parameter accepts only false and value values. With WordPress 3.9, the crop parameter now allows an array to be passed in to define the image cropping position.

Here’s an example with the $crop parameter is not defined:

add_image_size( 'new-image', 300, 300, true );

Here’s an example with the $crop parameter is used to set the crop position of the image:

add_image_size( 'new-image', 300, 300, array( 'left', 'top' ) );

For more information about this new enhancement, you may want to check the WordPress Codex page or ticket #19393 on WordPress core or WordPress Codex page.

This is just one of the enhancements added in WordPrss 3.9. If you’d like to discover all the new features in WordPress 3.9, be sure to read the official announcement of the release of WordPress 3.9 on WordPress.org site.

Comments

  1. Wade McMaster says

    It’s about time they got a feature like that on WordPress. I’ve always.found it to be such a stuff around editing a dire uploading photos for basic things like cropping. It’s good to see this one victory (among the many other of wp)

Leave a Reply

Your email address will not be published. Required fields are marked *