• Hi there,

    Is there a way to stop WordPress from creating multiple images when uploaded? It’s creating way too many images. I only want the one size that I uploaded.

    Is there some code I can add in my Functions.php file to prevent this?

    Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi There, you can use Disable Media Sizes plugin from the WordPress.org repo, full details you can find on the plugin page. If that solves the issue, kindly mark the topic as RESOLVED.

    Regards,
    Mohammad Arshad

    Moderator threadi

    (@threadi)

    The images generated there are thumbnails created by your theme or plugins for output in the frontend. This optimizes the output of your website.

    Without these mostly smaller images of the original, every visitor to your website would always load the large original images. This has the following effects:

    • The loading time of your page increases because each time megabytes more have to be loaded.
    • Mobile devices would consume an extremely large amount of traffic with this additional data, which would be at the expense of the internet connection
    • Google and other search engines would penalize your website due to the longer loading time, putting you at a disadvantage compared to your competitors

    If you want to reduce the number of thumbnails, first check which component in your project requests them. WordPress specifies a few sizes, your theme may also add some, and plugins can add them as well. Use https://wordpress.org/plugins/show-thumbnail-sizes-name/, for example, to see which sizes are generated in your project.

    If you think you can do without a size, check which component is responsible for it. Consider whether you will have a disadvantage in the website output if you do without the size. Then you could see if the component offers an option for this. If not, you have two options:

    Thread Starter MyWorldz

    (@myworldz)

    OMG!!! Why are there so many images? Please please tell me how to reduce it. I just need thumbnail, medium and large.

    thumbnail
    width => 150
    height => 150
    crop => TRUE

    medium
    width => 300
    height => 300
    crop => false

    medium_large
    width => 768
    height => 0
    crop => false

    large
    width => 1024
    height => 1024
    crop => false

    1536x1536
    width => 1536
    height => 1536
    crop => false

    2048x2048
    width => 2048
    height => 2048
    crop => false

    woocommerce_thumbnail
    width => 400
    height => 400
    crop => TRUE

    woocommerce_single
    width => 800
    height => 0
    crop => false

    woocommerce_gallery_thumbnail
    width => 200
    height => 200
    crop => TRUE
    Thread Starter MyWorldz

    (@myworldz)

    I have this in my template:

    // WooCommerce - Add theme support
    function mytheme_add_woocommerce_support() {
    add_theme_support( 'woocommerce', array(
    'thumbnail_image_width' => 400,
    'gallery_thumbnail_image_width' => 200,
    'single_image_width' => 800,

    'product_grid' => array(
    'default_rows' => 4,
    'min_rows' => 2,
    'max_rows' => 8,
    'default_columns' => 4,
    'min_columns' => 1,
    'max_columns' => 6,
    ),
    ) );
    }
    add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );
    Moderator threadi

    (@threadi)

    I have already described ways to change the thumbnail dimensions above. Have you already tested this, and if so, with what result?

    Thread Starter MyWorldz

    (@myworldz)

    Sorry I may be misunderstanding you. I would like to remove most of the sizes that are in the list that I added above – it’s way too many and I don’t know where some of them are coming from. I can then change the sizes under Settings > Media > in WordPress.

    So I guess what I would like now is to keep a few images sizes based on your reply above.

    Each item that I upload is creating 9 copies of the image.

    Thanks!

    • This reply was modified 8 months, 1 week ago by MyWorldz.
    Moderator threadi

    (@threadi)

    That’s exactly what I described to you above. Including all the possible disadvantages.

    Thread Starter MyWorldz

    (@myworldz)

    I tried code from the developer page in my functions file but that didn’t help, so I tried the Disable Media Sizes plugin but it only reduced the number of images created by 3, there are still 6 sizes are being created. I still don’t need that many. I disabled all but the media sizes.

    It’s also strange because I’m not using a lot of plugins, I wish there was a way to know exactly what plugin is creating those sizes – no wonder the images were taking forever to upload. These are the sizes that are still being created:

    800 x 800
    400 x 400
    300 x 300
    200 x 200
    150 x 150
    Another size that I’m not sure of

    Thanks!

    Thread Starter MyWorldz

    (@myworldz)

    I am totally stumped! Why is this so hard. I’ve been searching the internet and trying different things and nothing is working and I want it. Apparently the code below is used to prevent creating images but it does not work because some of the images are still been created. I also disabled the sizes under Settings > Media.

    // Prevent WordPress from Generating Image Sizes
    function gemini_turn_off_default_sizes ( $sizes ) {
    unset($sizes['thumbnail']); // Remove thumbnail size 150 x 150
    unset($sizes['medium']); // Remove medium size 300 x 300 (still created)
    unset($sizes['large']); // Remove large size 1024 x 1024
    unset($sizes['medium_large']); // Remove medium-large size 768 x 0
    unset($sizes['100x100']); // Remove 100 x 100 (still created)
    unset($sizes['600x600']); // Remove 600 x 600 (still created)
    unset($sizes['1536x1536']); // Remove 2x medium-large size (still created)
    unset($sizes['2048x2048']); // Remove 2x large size

    return $sizes;
    }
    add_filter( 'intermediate_image_sizes', 'gemini_turn_off_default_sizes' );

    This code works to upload only the original image, but the issue is that I would also like a thumbnail and medium size as well.

    // This code enables you to upload ONLY the original image to the server.
    Return false for calculated resized image dimensions
    add_filter( 'image_resize_dimensions', '__return_false' );

    Return an empty list of image sizes to generate on upload
    add_filter( 'intermediate_image_sizes_advanced', '__return_empty_array' );

    I really need to get this to work as the images are taking up too much space on the server.

    Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Stop WordPress From Creating Multiple Images When Uploaded’ is closed to new replies.