Site logo

[Support request] How to Deregister unused image sizes?

Home Forums Support [Support request] How to Deregister unused image sizes?

Home Forums Support How to Deregister unused image sizes?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1857489
    Atef

    Hi,
    I can see on my website that I have 3 unused image sizes. I assume they maybe generated by Generatepress?
    If so, how can I deregister them, please?
    the image size names are:
    medium_large: 768×0 pixels (proportionally resized to fit inside dimensions)
    1536×1536: 1536×1536 pixels (proportionally resized to fit inside dimensions)
    2048×2048: 2048×2048 pixels (proportionally resized to fit inside dimensions)

    Thanks in advance

    #1857577
    Elvin
    Staff
    Customer Support

    Hi there,

    You can use WordPress’ remove_image_size().
    https://developer.wordpress.org/reference/functions/remove_image_size/

    Here’s a good example:
    https://developer.wordpress.org/reference/functions/remove_image_size/#comment-2612

    Which we can basically rewrite to remove image sizes.

    Example:

    add_action( 'init', 'remove_sizes' );
    function remove_sizes() {
        remove_image_size( 'medium_large' );
        remove_image_size( '1536×1536' );
        remove_image_size( '2048×2048' );
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.