Skip to content

Instantly share code, notes, and snippets.

@probil
Created June 19, 2015 17:48
Show Gist options
  • Save probil/06e5806ac8b8a3e47520 to your computer and use it in GitHub Desktop.
Save probil/06e5806ac8b8a3e47520 to your computer and use it in GitHub Desktop.
Register thumbnail size only for specific post type (WP)
function set_different_post_type_sizes()
{
if (!empty($_REQUEST['post_id']) && ctype_digit($_REQUEST['post_id'])) {
if ('pedagogues' == get_post_type($_REQUEST['post_id'])) {
add_image_size('pedagogues-normal', 207, 250, true);
}
if ('slider' == get_post_type($_REQUEST['post_id'])) {
add_image_size('slider-normal', 891, 310, true);
}
if ('gallery' == get_post_type($_REQUEST['post_id'])) {
add_image_size('gallery-normal', 252, 252, true);
}
if ('groups' == get_post_type($_REQUEST['post_id'])) {
add_image_size('groups-normal', 200, 200, true);
}
if ('projects' == get_post_type($_REQUEST['post_id'])) {
add_image_size('projects-normal', 209, 196, true);
add_image_size('projects-big', 584, 584);
}
if ('news' == get_post_type($_REQUEST['post_id'])) {
add_image_size('news-normal', 209, 192, true);
add_image_size('news-big', 584, 584);
}
}
}
add_action('after_setup_theme', 'set_different_post_type_sizes');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment