• Resolved joycegrace

    (@joycegrace)


    Hello,

    Hello, I tried the method at the following link to disable image sizes being generated by WP core”: https://advent.elliottrichmond.co.uk/how-to-disable-all-unwanted-image-sizes/

    I tried this on an ‘untouched’ Twenty Twenty One theme. WP core is up to date and no plugins are active.

    When I take out the line for thumbnail (first line), and my Media settings set the thumbnail to 150×150, no matter what, the thumbnail does not generate when I upload a new image (refreshed media library page too, just in case, and I’m not trying to apply this retroactively to past images).

    My media settings: https://cloudup.com/cZL56bg8u74

    I have tried commenting out the other lines one-by-one, then refreshing the Media library and uploading a new image to see if something else is causing the thumbnail not to generate.

    Even when all the other lines are commented out (i.e. every other image size), the thumbnail does not generate. It’s only when I remove the code snippet entirely that the 150×150 thumbnail comes back when I upload a new image.

    See screenshot when code is enabled (without the thumbnail line): https://cloudup.com/cLAwg6E-sSo –> The 150×150 thumbnail is not generated.

    And when I remove all of it: https://cloudup.com/ciyBSt3Raa3 –> The 150×150 thumbnail is generated.

    Code I’m using in functions.php in Twenty Twenty One is as follows:

    // disable generated image sizes - https://advent.elliottrichmond.co.uk/how-to-disable-all-unwanted-image-sizes/
    function shapeSpace_disable_image_sizes($sizes) {
      unset($sizes['medium']); // disable medium size 
      unset($sizes['large']); // disable large size 
      unset($sizes['medium_large']); // disable medium-large size 
      unset($sizes['1536x1536']); // disable 2x medium-large size 
      unset($sizes['2048x2048']); // disable 2x large size return $sizes;
    }
    add_action('intermediate_image_sizes_advanced', 'shapeSpace_disable_image_sizes');
    
    // completely disable image size threshold - https://developer.www.ads-software.com/reference/hooks/big_image_size_threshold/
    add_filter( 'big_image_size_threshold', '__return_false' );

    When I add add_theme_support( 'post-thumbnails' ); nothing changes (it was my wild guess as to how to bring it back).

    Do you know why? How can this be fixed?

    I want to keep the 150×150 so that the Media Library can use that version of the image. Otherwise, in due time, I assume the Media library will be loading full-size (i.e. original) images which will take a long time to load.

    Thank you

    • This topic was modified 3 years, 4 months ago by joycegrace.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thank you for writing up your issue so thoroughly.

    I found a typo in the article where two separate lines were mistakenly combined.

    unset($sizes['2048x2048']); // disable 2x large size return $sizes;

    It’s important to return the $sizes array after updating it. Like so:

    unset($sizes['2048x2048']); // disable 2x large size
    return $sizes;

    The snippet with typo is half-working for you because it doesn’t allow any sizes to get through at all.

    Thread Starter joycegrace

    (@joycegrace)

    You know what, it took me two hours and eventually I figured this out!

    Ugh… one of those days.

    Thank you so much for responding to this, and so quickly too.

    I have notified the person who posted that original code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Thumbnail size not being generated’ is closed to new replies.