Using Default WordPress Custom Header Image Crop Feature in a Post Type / MetaBox

The question:

I am not sure how many of you have experimented with the new custom header image functionality of wordpress 3.0 but its actually very cool (enabled by adding the function to your functions.php file).

One of the key things which I find to be extremely useful is that it allows you to upload an image and on step 2 it actually places the image on the admin page and shows you a crop box based upon the header image width/height which was defined in your functions.php file. You now have the ability to move the box around or proportionally increase/decrease the size of the area you want to use.

The problem that I am having here is that I would like to utilize this functionality with my own custom post type. More specifically, I am just looking for the ability to include the upload functionality, defining the width/height and the select/cropping functionality once the image was uploaded. My thoughts are that if someone can show this can be done then I can create all the other functionality I am looking for by adding this to a custom post type and associating custom metaboxes.

Can anyone provide a solution here?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Take a look into /wp-admin/custom-header.php. You may extend the class Custom_Image_Header and adjust it to your needs.

Method 2

I am not really sure if this is what you are lookig for, but it seems like I was in the same boat you are in a couple months back working on a project I am about to launch. There is a plugin called Post Thumbnail Editor, and it allows you to custom crop every single image you upload according to the thumbnail sizes defined in your functions.php file.

Here is a guide to adding thumbnail sizes in WordPress using the add_image_size() function.

This worked wonders for us, and you can just define a different thumbnail size for each post type and call that specific size into the template for that CPT.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment