• Resolved protohominid

    (@protohominid)


    We have created some web stories that we want to keep, but will likely not be creating new ones going forward. For this reason, I’d like to keep the plugin from continuing to create 5 extra sizes of every image we upload. This effectively doubles our media library size for no good reason. Does anyone have an idea of how this could be done, short of deactivating the plugin?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Luckyna San

    (@luckynasan)

    @protohominid Thank you for your topic. Note there are a lot of factors that can influence what image size is served to visitors (device, screen size, etc). The editor will generate various thumbnail sizes for all your images and choose the most appropriate ones. The extra image sizes are needed to adhere to the Web Story format’s requirements for poster images and publisher logos. Unfortunately, WordPress does not provide any functionality for plugin developers to add image sizes only when needed and avoid creating unnecessary image sizes.

    Thread Starter protohominid

    (@protohominid)

    I’m not asking for the plugin to only add the sizes when needed; I’m asking if I can disable the creation of new sizes by the plugin going forward.

    WordPress has the “remove_image_size()” function, but I can’t get it to work on the Web Stories registered sizes. I tried it with the ‘init’ and ‘after_setup_theme’ action hooks.

    Why doesn’t the remove_image_size() function work in this case?

    This is my code:

    add_action( 'init', 'nm_remove_extra_images' );
    function nm_remove_extra_images() {
    	remove_image_size( 'web-stories-poster-portrait' );
     	remove_image_size( 'web-stories-poster-landscape' );
     	remove_image_size( 'web-stories-poster-square' );
     	remove_image_size( 'web-stories-publisher-logo' );
     	remove_image_size( 'web-stories-thumbnail' );
    }
    • This reply was modified 3 years, 6 months ago by protohominid.
    Plugin Author Pascal Birchler

    (@swissspidy)

    The plugin’s image sizes are registered on init with priority 10 (the default). If you want to remove them, use a higher number to call your function, e.g. add_action( 'init', 'nm_remove_extra_images', 20 );

    Thread Starter protohominid

    (@protohominid)

    Doh! I forgot to try adding the priority argument. That seems to have worked. Thanks Pascal!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Deregister image sizes?’ is closed to new replies.