WordPress.org

Forums

How Do You Remove Custom Media Sizes? (1 post)

  1. skinnytires
    Member
    Posted 2 years ago #

    So I've added custom image sizes:

    add_image_size( $name, $width, $height, $crop );

    And I see how you can remove DEFAULT image sizes:

    function my_remove_media_size( $sizes) {
    	unset( $sizes['thumbnail']);
    	unset( $sizes['medium']);
    	unset( $sizes['large']);
    	return $sizes;
    }
    add_filter('intermediate_image_sizes_advanced', 'my_remove_media_sizes');

    BUT, how do you remove CUSTOM image sizes? I understand that you just need to unset the custom media name ('thumbnail-portfolio' or whatever it is)... but how do you pass that additional argument to the 'my_remove_media_size' function?

    I understand that add_filter allows for additional args:

    add_filter( $tag, $function_to_add, $priority, $accepted_args );

    But from what I understand, WP is already passing the function the $sizes argument... so how do I pass an additional $my_custom_media_size_id = 'thumbnail-portfolio' argument from add_filter() that also includes the $sizes arg WP is already sending?

    Maybe its just a syntax issue I'm missing? Or is there something bigger I'm not grasping?

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic