Skip to content

Instantly share code, notes, and snippets.

@scrubmx
Created April 12, 2013 16:09
Show Gist options
  • Select an option

  • Save scrubmx/5373140 to your computer and use it in GitHub Desktop.

Select an option

Save scrubmx/5373140 to your computer and use it in GitHub Desktop.
Filter through wordpress and custom image sizes and remove unwanted fields from the array
add_filter( 'intermediate_image_sizes', function($sizes){
$type = get_post_type($_REQUEST['post_id']);
foreach($sizes as $key => $value){
if($type=='post_type' && $value != 'img_size_name'){
unset($sizes[$key]);
}
}
return $sizes;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment