Skip to content

Commit

Permalink
a11y: Prevent screen readers from reading twice
Browse files Browse the repository at this point in the history
This is a quick and dirty hack to prevent screen readers from reading
the content inside the `<figure>` tag twice.

Credit to @jcsteh (Jamie) at
https://matrix.to/#/!jmuErVonajdNMbgdeY:mozilla.org/$Esj2fvpJ5e2cJPZKQrCyzPBS8lnL0ZQc25vMMvW4lAM?via=mozilla.org&via=matrix.org&via=tchncs.de
  • Loading branch information
TheEvilSkeleton committed Jun 29, 2023
1 parent 1d31961 commit b5c582a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/_includes/image.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{% if include.caption != nil %}
<figure>
{% else %}
<figure aria-hidden="true">
{% endif %}
<figure aria-label="&nbsp;">
<img src="{{ include.url }}"
alt=""/>
<figcaption>{{ include.caption | markdownify }}</figcaption>
Expand Down
5 changes: 3 additions & 2 deletions src/_includes/video.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<figure>
<video src="{{ include.url }}"
<figure aria-label="&nbsp;">
<video aria-hidden="true"
src="{{ include.url }}"
controls="controls"
alt="">
</video>
Expand Down

2 comments on commit b5c582a

@jcsteh
Copy link

@jcsteh jcsteh commented on b5c582a Nov 27, 2024

Choose a reason for hiding this comment

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

Note that there is a proposed ARIA spec change that will avoid the need for this once implemented in browsers. See w3c/aria#2224.

@TheEvilSkeleton
Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks. I actually pushed this commit by accident because I accidentally set the remote to the wrong remote. I reverted that commit a few months ago because it was addressed in Firefox.

Please sign in to comment.