• I am working on a variation of a photo gallery plugin which is setting up a custom post type and some custom image sizes. The front end display of this custom post type will only ever use the custom sizes, it does not at all want anything to do with the default WordPress sizes. As such, I’d like to prevent the image generation of the thumbnail, medium and large versions which are automatically generated by WordPress on any uploaded image – but only when uploading during add/edit of the custom post type.

    Is this possible? If so, where do I start? Haven’t been able to find any actions/filters to help.

Viewing 1 replies (of 1 total)
  • Thread Starter Derek Ashauer

    (@sccr410)

    As usual, right after I post I find the solution:

    add_image_size( 'custom-thumbnail', 400, 300, true );
    add_image_size( 'custom-medium', 800, 800, false );
    
    add_filter('intermediate_image_sizes', 'change_image_sizes', 10, 1);
    function sunshine_change_image_sizes($image_sizes) {
    	if (get_post_type($_POST['post_id']) == 'my-cpt') {
    		unset($image_sizes);
    		$image_sizes[] = 'custom-thumbnail';
    		$image_sizes[] = 'custom-medium';
    	}
    	return $image_sizes;
    }

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your posted code may now have been permanently damaged/corrupted by the forum’s parser.]

Viewing 1 replies (of 1 total)
  • The topic ‘Preventing default image sizes from being made’ is closed to new replies.