change set_post_thumbnail_size according to post type admin page

Simpler way to figure out the post type of the item (which you are editing) and uploading media to:

$type = get_post_type($_REQUEST['post_id']);

As has been noted, the media upload iframe that is shown in the lightbox overlay when you try to upload something doesn’t indicate the parent post that new upload will be attached to. But the $_REQUEST is still active from the edit window, and still contains the post_id of the item you’re editing – so just query the type for that id…

You can use this technique in various hooks and filters – I’ve used the intermediate_image_sizes filter for image processing before, but not for this particular problem, but it should work there too…

Leave a Comment