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

Treatment of fallback image on <img src=''> #3280

Closed
mwenge opened this Issue Dec 8, 2017 · 7 comments

Comments

3 participants
@mwenge
Contributor

mwenge commented Dec 8, 2017

To my reading <img src=''> falls into the part of https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element that says: "If the src attribute is set and the alt attribute is not.. the user agent should display some sort of indicator that there is an image that is not being rendered".

In https://bugs.chromium.org/p/chromium/issues/detail?id=793206 we encountered interoperability issues because Blink now renders a fallback image in that case, rather then 'nothing' like other browsers.

As far as I can see Blink is following the spec here, unless src is not considered 'set' when src=''.

Have I misunderstood the meaning of 'set' in this case? And if not, should the spec be changed to allow rendering 'nothing' in this case as it is what all browsers do (apart from Blink since Chrome M63)? (Although FF is the only other browser that currently attempts to follow this part of the spec, and it seems to treat src='' as 'not set'.

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Dec 12, 2017

Member

Your understanding of "set" is correct. This is a bit more complex though, as it appears to depend on the width/height: https://jsbin.com/foyapuz/1/edit?html,output

Note that per the normative text in https://html.spec.whatwg.org/#update-the-image-data, src="" always causes a broken image. (Instead of, e.g., fetching the contents of the base URL after resolving the empty string against the page's base URL.)

Based on the above test case appear to be several behaviors in current browsers for broken images:

  • Firefox, Chrome 62, Safari Tech Preview:
    • width/height causes broken image placeholders to always be shown
    • no width/height causes broken image placeholders to be shown unless src=""
    • Safari seems to use a different broken image placeholder for src="" than for src="asdf"
  • Edge:
    • src="" causes no placeholders to be shown; otherwise, they are shown
  • Chrome 63:
    • shows broken image placeholders always, although src="" broken images get a different placeholder than src="asdf"

So I guess we should update the spec to point toward the first option here, revert the Chrome change, and file an Edge bug? What do you think?

Member

domenic commented Dec 12, 2017

Your understanding of "set" is correct. This is a bit more complex though, as it appears to depend on the width/height: https://jsbin.com/foyapuz/1/edit?html,output

Note that per the normative text in https://html.spec.whatwg.org/#update-the-image-data, src="" always causes a broken image. (Instead of, e.g., fetching the contents of the base URL after resolving the empty string against the page's base URL.)

Based on the above test case appear to be several behaviors in current browsers for broken images:

  • Firefox, Chrome 62, Safari Tech Preview:
    • width/height causes broken image placeholders to always be shown
    • no width/height causes broken image placeholders to be shown unless src=""
    • Safari seems to use a different broken image placeholder for src="" than for src="asdf"
  • Edge:
    • src="" causes no placeholders to be shown; otherwise, they are shown
  • Chrome 63:
    • shows broken image placeholders always, although src="" broken images get a different placeholder than src="asdf"

So I guess we should update the spec to point toward the first option here, revert the Chrome change, and file an Edge bug? What do you think?

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Dec 13, 2017

Member

Note that the img loading model also disregards empty string src attributes. A clean solution here would to observe some internal state of the img element not having a "source" (determined while running "update the image data") as then we don't have to observe the empty string thing in two places.

Member

annevk commented Dec 13, 2017

Note that the img loading model also disregards empty string src attributes. A clean solution here would to observe some internal state of the img element not having a "source" (determined while running "update the image data") as then we don't have to observe the empty string thing in two places.

@mwenge

This comment has been minimized.

Show comment
Hide comment
@mwenge

mwenge Dec 15, 2017

Contributor

Blink reverted to its previous treatment of SRC='' under the chromium bug I quoted so it would certainly be great to get the spec updated to match the preferred behaviour for the SRC='' case.

Contributor

mwenge commented Dec 15, 2017

Blink reverted to its previous treatment of SRC='' under the chromium bug I quoted so it would certainly be great to get the spec updated to match the preferred behaviour for the SRC='' case.

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Dec 15, 2017

Member

@mwenge would you be interested in writing such a change?

Member

annevk commented Dec 15, 2017

@mwenge would you be interested in writing such a change?

@domenic domenic closed this in #3311 Jan 2, 2018

domenic added a commit that referenced this issue Jan 2, 2018

Clarify image display when src is an empty string
When src is an empty string (<img src='') and the alt attribute
is not set UAs currently agree that nothing should be displayed.
Update the rules to specify this behaviour.

Closes #3280.
@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Jan 3, 2018

Member

Reopening so this feedback by @triple-underscore is considered:

Seems that, the newly added text is misplaced under the case “...the alt attribute is set to a value that isn't empty”.
(Should be placed under the case “If the src attribute is set and the alt attribute is not” ?)

Member

annevk commented Jan 3, 2018

Reopening so this feedback by @triple-underscore is considered:

Seems that, the newly added text is misplaced under the case “...the alt attribute is set to a value that isn't empty”.
(Should be placed under the case “If the src attribute is set and the alt attribute is not” ?)

@mwenge

This comment has been minimized.

Show comment
Hide comment
@mwenge

mwenge Jan 3, 2018

Contributor

That was dumb. :)

Contributor

mwenge commented Jan 3, 2018

That was dumb. :)

@domenic domenic closed this in #3320 Jan 4, 2018

domenic added a commit that referenced this issue Jan 4, 2018

Clarify image display when src is an empty string, again
Fix commit e78f98b
which added the text to the wrong paragraph.

Closes #3280, again.
@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic
Member

domenic commented Jan 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment