-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<picture>
and <source>
elements: How should 404s with placeholder image data be handled?
#8916
Comments
Even more bizarre is that the standard's text for the
Of course, I'm not sure the above code complies with the spec behavior either. If a |
Is "placeholder" just your word for "a 404 response"? |
More or less, yes; in this context, I was using it to mean "a 404 response that has valid image data attached, that a browser can display." Apologies -- I should've been more explicit about that. |
This seems like a specification bug to me. We shouldn't use different fetching rules from |
This algorithm does not apply to The relevant algorithm for The "try next Maybe the spec should be clearer that the "resource selection algorithm" doesn't apply for |
That, and I need to be more attentive. I found the link to the resource selection algorithm at the bottom of the section for Some other notes re: clarity though: The section for The section for
Thanks for the info. Did some research to try and understand this better... It looks like that was decided upon here in order to have |
It's possible for a request for an image to receive a 404 response that has an image Content-Type with valid image data attached, to be displayed as a placeholder. Currently,
img
elements are required to display this placeholder data (per 4.8.4.3 Processing Model):What's less clear is how this should apply to the case of
picture
elements with a list ofsource
s, when one of those sources fails with a placeholder 404 image.The status quo
My understanding of the spec is that if a
source
fails with a 404, regardless of whether placeholder data is received, the browser is supposed to try the nextsource
in the list:source
's target resource be fetched using the resource fetch algorithm.source
(if any) and trying that one.It seems that the spec-compliant behavior would be:
source
fails with a 404, try the nextsource
, regardless of whether the failingsource
had placeholder image data attached to the 404 response.source
s fail, and theimg
also fails, then use only any placeholder image data attached to theimg
's 404 response. If theimg
404 response did not contain placeholder data, then display a broken image (i.e. no placeholder data from anysource
will be used).Current browser behavior
If Chromium and Mozilla Firefox encounter a
source
that 404s with placeholder content, they will display that placeholder content, instead of making any attempt to try the next source(s) in the list. Additionally, neither browser makes any attempt to try more than the firstsource
with a supported MIME type. Consider the code below:We are here trying to display the YouTube thumbnail for Rick Astley's "Never Gonna Give You Up." There are multiple possible URLs for a YouTube thumbnail, and not all such URLs are available for every video; additionally, if any image request to the YouTube thumbnail server fails, the server returns a 404 response with a 120x90px
image/jpeg
placeholder attached. This placeholder is what the above code displays in Firefox and Chromium. If we uncomment the obviously brokenexample.com
URL, then Firefox and Chromium just display a broken image; watching the network requests allows us to see that they never attempt to request anything else after failing to loadnonexistent.png
.It seems, then, like a key portion of the spec for
picture
andsource
elements is completely unimplemented in every major browser.So I guess my questions are...
Should the spec be amended to match existing browser behavior? It seems like it'd be far more useful if web browsers actually implemented the "try each source until one works" part of the spec instead.
Suppose that web browsers were to ignore 404 placeholder data on a
source
: if asource
404s, the browser tries the nextsource
or, if none remain, theimg
, instead of just displaying any placeholder data that was sent along with the 404.If all
source
s fail, theimg
also fails, and one or moresource
s had placeholder data, then should the spec be amended to have the browser display one of thosesource
s' placeholders? Should the browser prefer the earliestsource
in the list that had a placeholder? Should the browser prefer theimg
placeholder, if one was received, over allsource
placeholders?I don't know terribly much about how network requests are done under the hood, but I'd imagine that if browsers can use the earliest placeholder in the list, then they don't have to actually bother to fully load the placeholders for any failing
source
elements after that one....Am I even interpreting these parts of the spec properly to begin with?
The text was updated successfully, but these errors were encountered: