Skip to content
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

-moz-force-broken-image-icon: alt text on height OR width set #37261

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

SVNKoch
Copy link

@SVNKoch SVNKoch commented Dec 18, 2024

before: if height and width is set
after: if height or width is set

Description

moz-force-broken-image-icon specified, that alt text will not be shown if height and width is set. Changed it to an or.
And reworded sentence to make it simpler to read; converted alt to alt.

Motivation

the wiki talks about "has a specified height and width"
but it should be an "or" as showcased by this playground
grafik
specifically look at the second to fourth line / image.

Additional details

Related issues and pull requests

@SVNKoch SVNKoch requested a review from a team as a code owner December 18, 2024 13:31
@SVNKoch SVNKoch requested review from estelle and removed request for a team December 18, 2024 13:31
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/xs [PR only] 0-5 LoC changed labels Dec 18, 2024
before: if height and width is set
after: if height or width is set
@GorbachovMaina1

This comment was marked as off-topic.

@SVNKoch SVNKoch marked this pull request as ready for review December 28, 2024 23:47
@estelle estelle requested review from bsmth and removed request for estelle December 29, 2024 05:21
Copy link
Contributor

github-actions bot commented Dec 30, 2024

Preview URLs

Flaws (48)

URL: /en-US/docs/Web/CSS/-moz-force-broken-image-icon
Title: -moz-force-broken-image-icon
Flaw count: 48

  • macros:
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Learn/CSS
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Learn/Getting_started_with_the_web/CSS_basics
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Learn/CSS/First_steps
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Learn/CSS/First_steps/What_is_CSS
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Learn/CSS/First_steps/Getting_started
    • and 43 more flaws omitted

(comment last updated: 2024-12-30 12:55:06)

@SVNKoch
Copy link
Author

SVNKoch commented Dec 30, 2024

preview looks good in my opinion

@bsmth
Copy link
Member

bsmth commented Dec 30, 2024

Is it not like the following for -moz-force-broken-image-icon: 1 cases:

If an image has no height or width set, the alt text may not be visible.

@bsmth
Copy link
Member

bsmth commented Dec 30, 2024

For -moz-force-broken-image-icon:

A value of 1 means that the broken image icon is shown even if the image has an alt attribute.
When the value 0 is used, the image will act as usual and only display the alt attribute.

I think the images in your example don't show the alt text because the element is too small: https://codepen.io/bsmth/pen/qEWPqEE

@SVNKoch
Copy link
Author

SVNKoch commented Dec 30, 2024

I think the images in your example don't show the alt text because the element is too small

Nope, you are mistaken, see
grafik

sources

<h1>no force</h1>
<img class="no-force         " src="x.png" alt="ALT"                            />
<img class="no-force         " src="x.png" alt="ALT" width="50px"               />
<img class="no-force         " src="x.png" alt="ALT"              height="50px" />
<img class="no-force         " src="x.png" alt="ALT" width="50px" height="50px" />
<br>
<img class="no-force         " src="x.png"                                      />
<img class="no-force         " src="x.png"           width="50px"               />
<img class="no-force         " src="x.png"                        height="50px" />
<img class="no-force         " src="x.png"           width="50px" height="50px" />
<br>
<img class="no-force min-size" src="x.png" alt="ALT"                            />
<img class="no-force min-size" src="x.png" alt="ALT" width="50px"               />
<img class="no-force min-size" src="x.png" alt="ALT"              height="50px" />
<img class="no-force min-size" src="x.png" alt="ALT" width="50px" height="50px" />
<br>
<img class="no-force min-size" src="x.png"                                      />
<img class="no-force min-size" src="x.png"           width="50px"               />
<img class="no-force min-size" src="x.png"                        height="50px" />
<img class="no-force min-size" src="x.png"           width="50px" height="50px" />

<h1>with force</h1>
<img class="do-force         " src="x.png" alt="ALT"                            />
<img class="do-force         " src="x.png" alt="ALT" width="50px"               />
<img class="do-force         " src="x.png" alt="ALT"              height="50px" />
<img class="do-force         " src="x.png" alt="ALT" width="50px" height="50px" />
<br>
<img class="do-force         " src="x.png"                                      />
<img class="do-force         " src="x.png"           width="50px"               />
<img class="do-force         " src="x.png"                        height="50px" />
<img class="do-force         " src="x.png"           width="50px" height="50px" />
<br>
<img class="do-force min-width" src="x.png" alt="ALT"                            />
<img class="do-force min-width" src="x.png" alt="ALT" width="50px"               />
<img class="do-force min-width" src="x.png" alt="ALT"              height="50px" />
<img class="do-force min-width" src="x.png" alt="ALT" width="50px" height="50px" />
<br>
<img class="do-force min-width" src="x.png"                                      />
<img class="do-force min-width" src="x.png"           width="50px"               />
<img class="do-force min-width" src="x.png"                        height="50px" />
<img class="do-force min-width" src="x.png"           width="50px" height="50px" />
<br>
<img class="do-force min-height" src="x.png" alt="ALT"                            />
<img class="do-force min-height" src="x.png" alt="ALT" width="50px"               />
<img class="do-force min-height" src="x.png" alt="ALT"              height="50px" />
<img class="do-force min-height" src="x.png" alt="ALT" width="50px" height="50px" />
<br>
<img class="do-force min-height" src="x.png"                                      />
<img class="do-force min-height" src="x.png"           width="50px"               />
<img class="do-force min-height" src="x.png"                        height="50px" />
<img class="do-force min-height" src="x.png"           width="50px" height="50px" />
<br>
<img class="do-force min-width min-height" src="x.png" alt="ALT"                            />
<img class="do-force min-width min-height" src="x.png" alt="ALT" width="50px"               />
<img class="do-force min-width min-height" src="x.png" alt="ALT"              height="50px" />
<img class="do-force min-width min-height" src="x.png" alt="ALT" width="50px" height="50px" />
<br>
<img class="do-force min-width min-height" src="x.png"                                      />
<img class="do-force min-width min-height" src="x.png"           width="50px"               />
<img class="do-force min-width min-height" src="x.png"                        height="50px" />
<img class="do-force min-width min-height" src="x.png"           width="50px" height="50px" />
img { margin: 1rem; }
.min-width { min-width: 100px; }
.min-height { min-height: 100px; }
.do-force { -moz-force-broken-image-icon: 1; }
.no-force { -moz-force-broken-image-icon: 0; }

as we can see, the alt text is showing for elements which have (an alt text and) width or height specified (either explicitly or via min-width /-height or both).

PS: but I think the statement is correct that the alt text only shows when the (broken) image is large enough. This is why it is coded such that it is only shown when some size is specified, I would guess.

@bsmth
Copy link
Member

bsmth commented Dec 31, 2024

I just had a read through again, and I don't think it's right. Let's recap:

  • If the image doesn't load and there's alt text, the alt text is displayed inline instead of the image:

    <img src="broken-image.png" alt="Display me instead" />
  • If the image doesn't load and there's alt text, when you set -moz-force-broken-image-icon: 1, you'll see the broken image icon:

    <img src="alt.png" alt="Broken image link" style="-moz-force-broken-image-icon: 1"/>

The width only affects whether there is room to see the text in the second case, so I think the original is more correct.

You can have a look at the preview here:

https://pr37261.content.dev.mdn.mozit.cloud/en-US/docs/Web/CSS/-moz-force-broken-image-icon#css

image

Where:

  1. -moz-force-broken-image-icon: 1; -> applied
  2. "the image has a specified height or width" -> true (both)
  3. "the alt attribute will not be displayed" -> not correct

I think a better note might be that the alt text may not be visible if the image width and height are not large enough. Do you agree?

@bsmth bsmth added the awaiting response Awaiting for author to address review/feedback label Jan 3, 2025
@@ -55,7 +55,7 @@ img {
{{EmbedLiveSample('Examples','125','125')}}

> [!NOTE]
> Unless the image has a specified height and width the alt attribute will not be displayed if `-moz-force-broken-image-icon` is set to `1`.
> If `-moz-force-broken-image-icon` is set to `1`, the `alt` attribute will not be displayed if the image has a specified height or width.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> If `-moz-force-broken-image-icon` is set to `1`, the `alt` attribute will not be displayed if the image has a specified height or width.
> Alt text may not be visible if `-moz-force-broken-image-icon` is set to `1` and an image has no (or too small) `height` or `width` set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Awaiting for author to address review/feedback Content:CSS Cascading Style Sheets docs size/xs [PR only] 0-5 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants