How can I make add_image_size() crop from the top?

Posted by Editorial Staff | Updated on

Intermediate image generation is extremely rigid. image_resize() keeps it close to code and completely lacks hooks.

Pretty much only option for this is to hook into wp_generate_attachment_metadata and overwrite WP-generated image with your own (which will need bit of a image_resize() fork).

I need this for work so I might be able to share some code later.

Ok, here is rough, but working example. Note that setting up crop in this way requires understanding of imagecopyresampled().


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers