Disabling auto-resizing of uploaded images

Whenever I upload a large image, it gets resized to the width of the post. This will be a negative feature for comic reading sites. I need to display the full width images, which I can resize when I need during upload.

If anything that can fix this issue?

Related posts

2 comments

  1. To disable resizing for all image sizes without manually removing each size with remove_image_size function, use the filter intermediate_image_sizes_advanced

    /**
     * @param array $sizes    An associative array of image sizes.
     * @param array $metadata An associative array of image metadata: width, height, file.
     */
    function remove_image_sizes( $sizes, $metadata ) {
        return [];
    }
    add_filter( 'intermediate_image_sizes_advanced', 'remove_image_sizes', 10, 2 );
    
  2. WordPress resizes its images into 3 default sizes:

    • Large (Default: 1024 × 1024)
    • Medium (Default: 300 × 300)
    • Thumbnail (Default: 150 × 150)

    And in all the three cases WordPress simply crop them from middle by default, and make their different versions for different use cases. It’s done to ensure speed.

    When we call a featured image in somewhere we simply call the size inside the function like:

    the_post_thumbnail( 'large' );
    

    Okay, now the good news is, though WordPress resizes all the uploaded images, it keeps the original one intact, and we can use the original one too, wherever necessary. To use the original file, you just need to call:

    the_post_thumbnail('full');
    

    So, the problem is now on your theme file. You need to modify the theme file to change the code into something like this.

    Disabling resizes

    From admin panel

    Though it’s not related for your cause, but to stop those auto resizing, follow the simple steps:

    • In /wp-admin from Settings » Media
    • Now in Large, Medium and Thumbnail sizes, simply put zero (0) into their width and height.
    • Now Save changes.

    It’ll stop those resizes from the future uploads. 🙂

    Using code

    You can use remove_image_size() function into your functions.php to disable all the three default image sizes:

    remove_image_size('large');
    remove_image_size('medium');
    remove_image_size('thumbnail');
    

    It will stop resizing the images into those sizes.

    Reference

Comments are closed.