Skip to content

Commit e554e3a

Browse files
authored
fix a11y of the figure shortcode (#2788)
* fix a11y of the figure shortcode Signed-off-by: HarHarLinks <[email protected]> * Update CONTENT.md --------- Signed-off-by: HarHarLinks <[email protected]>
1 parent b8e18bd commit e554e3a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CONTENT.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ It is possible to add pictures to your posts in markdown. First you need to drop
6262
```jinja
6363
{{ figure(
6464
img="/blog/img/your-picture-name.avif"
65-
caption="A description of the picture")
66-
}}
65+
caption="A description of the picture" # can be set to an empty string
66+
alt="A picture description for screen readers" # optional, should only be used when leaving the caption empty
67+
) }}
6768
```
6869

6970
This shortcode ensures that images have a consistent look across posts.

templates/shortcodes/figure.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<figure style="height:100%;">
2-
<img src="{{ img }}" alt="{{ caption }}" />
2+
<img src="{{ img }}" {% if alt %}alt="{{ alt }}{% endif %}" />
33
<figcaption>{{ caption | markdown | safe }}</figcaption>
4-
</figure>
4+
</figure>

0 commit comments

Comments
 (0)