• Hello,

    When I enable Lazy Loading I get a validation error

    “The sizes attribute may be specified only if the srcset attribute is also present.”

    Any idea what causing this error?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Dimitar Terziev

    (@dimitart)

    Hello @anzach,

    The W3C validator will trigger this error if sizes attribute is set but srcset is not. I was unable to replicate it on my end.

    Could you please provide us with your site’s URL, so we can take a closer look on this?

    Best Regards,
    Dimitar Terziev

    Thread Starter Antonis Zachos

    (@anzach)

    Hi,

    The website is davvero.gr

    Thanks is advance!

    A.

    Plugin Support Dimitar Petrov

    (@demiro)

    Thank you for the update.

    I have checked your website and noticed that the Lazy Load feature is currently activated.

    The W3C validator is indeed reporting the issue in question. Please note that this tool loads the HTML output without being an actual browser, so we could consider this as speculative parsing.

    The srcset attribute is actually added, correctly, following the best practices to be defined as data-srcset. When the Lazy Load feature is disabled, the srcset attribute is not converted to data-srcset and this is why the validator does not report any errors.

    Defining the attribute dynamically, as data-srcset, we avoid loading the image in non-browser requests(speculative parsing). This is why you can safely disregard those warnings.

    In order to fully confirm that the attribute is passed correctly, you could
    open your website directly in your browser, right-click on some image and click the Inspect(or Inspect Element) button. The srcset attribute should exist. In case it is missing on specific images, revise the way you are including these images to your posts, as WordPress by default adds srcset attribute.

    Best Regards,
    Dimitar Petrov

    Thread Starter Antonis Zachos

    (@anzach)

    Thank you for you valuable information!

    A.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘The sizes attribute may be specified only if the srcset attribute is also presen’ is closed to new replies.