Skip to content

Instantly share code, notes, and snippets.

@MikeiLL
Created May 24, 2017 15:55
Show Gist options
  • Select an option

  • Save MikeiLL/f3e4b916a7fd1332451a44263af52feb to your computer and use it in GitHub Desktop.

Select an option

Save MikeiLL/f3e4b916a7fd1332451a44263af52feb to your computer and use it in GitHub Desktop.
/**
* Add & remove image sizes from the "Image Sizes" panel
*
* @since 1.0.0
* source: https://wpexplorer-themes.com/total/snippets/addremove-image-sizes/
*/
public static function cpt_image_sizes( $sizes ) {
// Remove "blog_post_full" image size
unset( $sizes['blog_post_full'] );
// Add new image size "my_image_sizes"
$sizes['cpt_image_size'] = array(
'label' => __( 'Image sizes for Slider Entry displays', 'wpex' ), // Label
'width' => 'cpt_image_size_width', // id for theme_mod width
'height' => 'cpt_image_size_height', // id for theme_mod height
'crop' => 'cpt_image_size_crop', // id for theme_mod crop
);
// Add new image size "my_image_sizes"
$sizes['services_archive'] = array(
'label' => __( 'Image sizes for Archive Entry displays', 'wpex' ), // Label
'width' => 'archive_image_size_width', // id for theme_mod width
'height' => 'archive_image_size_height', // id for theme_mod height
'crop' => 'archive_image_size_crop', // id for theme_mod crop
);
// Return sizes
return $sizes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment