• Hi,

    I want to use image in exact size 800x533px (registered size for WooCommerce Single products) and WordPress is still adding srcset and sizes attributes with nonsense values like this:

    <img loading="lazy" decoding="async" width="800" height="533" src="https://www.mywebsite.com/media/2025/09/homepage-cestovani-800x533.png" class="attachment-woocommerce_single size-woocommerce_single wp-image-7256" alt="" srcset="https://www.mywebsite.com/media/2025/09/homepage-cestovani-800x533.png 800w, https://www.mywebsite.com/media/2025/09/homepage-cestovani-300x200.png 300w, https://www.mywebsite.com/media/2025/09/homepage-cestovani-1024x683.png 1024w, https://www.mywebsite.com/media/2025/09/homepage-cestovani-768x512.png 768w, https://www.mywebsite.com/media/2025/09/homepage-cestovani-990x660.png 990w, https://www.mywebsite.com/media/2025/09/homepage-cestovani-441x294.png 441w, https://www.mywebsite.com/media/2025/09/homepage-cestovani-150x100.png 150w, https://www.mywebsite.com/media/2025/09/homepage-cestovani.png 1536w" sizes="(max-width: 360px) 330px, (max-width: 800px) 100vw, 800px">

    Nonsense:

    1. It used original image 1536×1536 for <img width=”800″ height=”533″>
      • = horribly bad aspect ratio, too big image
    2. etc.

    There are 2 main problems:

    1. I set width=”800″ height=”533″ so I want to always use image image-800×533.jpg
    2. Even if I want to use smaller responsive images, I don’t want to use larger responsive images because I know that on any screen (100000x100000px) in layout the image will not show larger than 800x533px.
      • Like: you have your website 1024 width so you know images on this website will be never more width than 1024.
      • (Image is not used for anything like full screen detailed showing.

    Is it known issue which WordPress is working on?

    Is there a fix for now?

    Regards,

    Jiri Polacek

Viewing 1 replies (of 1 total)
  • Moderator threadi

    (@threadi)

    I assume you are referring to the information in srcset, which defines which graphics should be used for output on different devices. This optimizes the loading times of the page and also leads to positive ratings from Google and ultimately to better findability of your page in search results. On a phone, for example, your preferred graphic with a width of 800 pixels would not be displayed at all in this width, but with 350-760 depending on the phone-type. If it were still loaded with these bigger dimensions, the displaying device would waste additional bytes, which would affect both the loading and the rendering time. That’s why HTML has the srcset attribute, so that the browser can decide for itself which size of the graphic to load.

    The information contained in srcset depends heavily on the theme used. WordPress provides a few default values for this, but the theme decides which ones to use and output here. Optimization plugins can also interfere here, as they want to optimize the page for different end devices as described above.

    To answer your question, we would need to know more about your project, e.g., which theme you are using and whether and which optimization plugins you are using. A link to the page could also help.

    If you don’t want to show this, you can try to influence the information in srcset yourself. With the hook wp_calculate_image_srcset, you can change or even empty the list. All srcset information should be removed with the following code:

    add_filter( ‘wp_calculate_image_srcset’, ‘__return_empty_array’, PHP_INT_MAX );

    I haven’t tested this yet, but you’re welcome to give it a try. The information would need to be added to the functions.php of your child theme or via the Code Snippet plugin in the project. Please note, however, that this will have a negative impact on your page’s loading times, including its search engine visibility.

Viewing 1 replies (of 1 total)

The topic ‘WordPress is adding nonsense srcset’ is closed to new replies.