cmoreira

lock thumb creation to ttshowcase

Jan 18th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. /* With this function, thumbnails for ttshowcase will only get created when getting upload inside the ttshowcase custom post type */
  2. add_filter( 'intermediate_image_sizes', 'ttshowcase_image_sizes_lock', 999 );
  3. function ttshowcase_image_sizes_lock( $image_sizes ){
  4.  
  5.     $ttshowcase_sizes = array( 'ttshowcase_small', 'ttshowcase_normal' );
  6.  
  7.     if( isset($_REQUEST['post_id']) && 'ttshowcase' != get_post_type( $_REQUEST['post_id'] ) ) {
  8.         $image_sizes = array_diff($image_sizes, $ttshowcase_sizes);
  9.     }
  10.      
  11.     return $image_sizes;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment