I'm having a mystery here. The issue itself is worked around by now, but I still can't see the actual cause: On our image sharing site Pixabay.com we recently implemented the srcset
attribute for img
tags on search results. You can see that in action here: https://pixabay.com/photos/
A typical img
tag in there looked like this:
<img src="/image__180.jpg" srcset="/image__180.jpg 1x, /image__340.jpg 2x" alt="...">
It worked very well - for about 99% of all users. However, a few reported to see the issue depicted in this screenshot:
Some 30-50 images loaded correctly on the page, while the others resulted in broken images. We realized, our NGINX log contained a few errors like this:
open() "/.../image__180.jpg" srcset="/image__180.jpg 1x, /image__340.jpg 2x" failed (2: No such file or directory)
Apparently, for an unknown reason, the client requested the whole expression (value of src+"srcset"+value of srcset) as image path, which of course resulted in an error 404.
We played around a bit and realized, first providing the srcset
and then the src
attribute on the img
tags solves the issue. No more error logs, no more complaints.
<img srcset="/image__180.jpg 1x, /image__340.jpg 2x" src="/image__180.jpg" alt="...">
I couldn't find any reports of this behavior anywhere on the web. But I'd like to learn more. Here's the discussion on Pixabay with several users reporting the issue: https://pixabay.com/en/forum/help-me-please-11/pixabay-technical-difficulties-1474/?pagi=2
Do you have an explanation?