• Resolved Anonymous User 14808221

    (@anonymized-14808221)


    In WordPress to stop WordPress generating place-wasting thumbnails and other image sizes, we can add 0 to the width and height settings in Dashboard > Settings > Media

    When we add 0 then it successfully stops WordPress fro creating the intermediary sizes. Good!

    But for whatever reason, medium_large size is still added, even if we set it to 0.
    The only way of stopping this snowflake is to

    
    add_filter( 'intermediate_image_sizes', function( $sizes )
    {
        return array_filter( $sizes, function( $val )
        {
            return 'medium_large' !== $val; // Filter out 'medium_large'
        } );
    } );
    

    Why is this?
    Why is this not just handled centrally like with any other image size?
    Usually we can do this:

    
    add_action( 'init', 'remove_extra_image_sizes');
    function remove_extra_image_sizes() {
        foreach ( get_intermediate_image_sizes() as $size ) {
            if ( !in_array( $size, array( 'a_size', 'another_size' ) ) ) {
                remove_image_size( $size );
            }
        }
    }
    

    WP medium_large size seems to be somehow out of the usual flow.

    Thoughts?

    Cheers..

    • This topic was modified 4 years, 6 months ago by Anonymous User 14808221.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    I do believe that the intermediate_image_sizes hook is the proper way to manage image sizes since it can be managed per (post/taxonomy) type.

    One reason may be that the medium_large size is used specifically for the Media Library. When removed the Media Library will instead pull in the full image which can greatly increase the load of both the page and modal window. I wouldn’t recommend removing it or unsetting it.

    Thread Starter Anonymous User 14808221

    (@anonymized-14808221)

    Hi, that makes sense!

    Thanks for pointing it out…

    is used specifically for the Media Library

    The modal is using 'medium' size and everywhere else is full image served. I have never seen the medium_large in backend, only as srcset crap in front end. Correct me if Im wrong.

    Thread Starter Anonymous User 14808221

    (@anonymized-14808221)

    @jonas-lundman – it seems you are right

    https://make.wordpress.org/core/2015/11/10/responsive-images-in-wordpress-4-4/ introduced it and says

    A new default intermediate size, medium_large, has been added to better take advantage of responsive image support.

    I didn’t really check back then where the size may be used, I simply removed it (after finding the proper filter for it).

    Since I use custom front end display modes I think it is also safe to remove it without somehow “ruining” WPs srcset

    In any case I couldn’t see any issue with images related to intermediate sizes since I removed it.

    The whole “confusion” on my end rather was due to the fact that (like so many other times) in WP we can’t use “one thing to do the same thing twice” (like remove image intermediate sizes), we often need to use “two different things to do the same thing” :rofl:

    Thanks!

    Yes I agree.

    The medium_large image size is a relic, and srcset in many cases, as we can use CSS level object-fit. As for SEO, we also try to serve ONE image, SAME size, SAME optimized to be ranked by search engines. And medium_large 768px SIZE is quite good size for the latter. AND, every install have it, and a WordPress Theme / developer can use it front end without need of regenerate new sizes.

    But as Y mentioned, it has to be initiated twice / a second time by: register a custom image size, lets say “normal” with the EXACT size as medium_large. THEN we can access it as ‘normal‘ image-size everywhere just like post-thumbnail, medium or large

    • This reply was modified 4 years, 1 month ago by Jonas Lundman. Reason: spelling
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘medium_large image size is still generated even if set to 0’ is closed to new replies.