Crop WordPress post thumbnails from the top

I have just been going through the process of auto cropping featured image sizes so they all look same size on a site I’ve been building recently.  I was using the “hard crop” parameter of the add_image_size function to crop all my featured post images so they adopt a king of ‘letterbox’ shape using the dimensions 800×200.

The only trouble with his was that WordPress crops the image from the middle so it cut of the tops of people’s heads on some of the images and generally made other images look a bit crap.

I wanted to be able to crop the image from the top, rather the middle, but WordPress doesnt do this out of the box.  Fortunately, I stumbled across this awesome patch called Image Crop Position in WordPress{#post-9767} by Brad Touesnard.

You have to copy his code view it on Github here into your functions.php and you can then use the new parameter called array where you can specify left or top.  See below:

add_image_size( ‘custom-1’, 800, 280, array( ‘left’, ‘top’ ) );

Lovely stuff!

Contact Me