Skip to content

Commit

Permalink
Fixed alt text checking when the alt-text is artificially empty (with…
Browse files Browse the repository at this point in the history
… two doublequotes).
  • Loading branch information
khalima committed Nov 15, 2022
1 parent e2e03c1 commit 9fe3c25
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
3 changes: 2 additions & 1 deletion hdbt_admin.theme
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,9 @@ function hdbt_admin_preprocess_media(&$variables) {
}

if ($variables['media']->hasTranslation($current_language)) {
$variables['alt_text'] = $variables['media']
$alt = $variables['media']
->getTranslation($current_language)->field_media_image->alt;
$variables['alt_text'] = $alt !== '""' ? $alt : FALSE;
}
}
}
12 changes: 5 additions & 7 deletions templates/entity/media--media-library.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,15 @@
<div{{ metadata_attributes.addClass('media-library-item__attributes') }}>
<div class="media-library-item__name">{{ name }}</div>

{% if alt_text %}
<div class="media-library-item__alt">
<div class="media-library-item__alt">
{% if alt_text %}
{{ 'Alt'|t({}, {'context': 'Alt text in media library'}) }}:
<span>{{ alt_text }}</span>
</div>
{% else %}
<div class="media-library-item__alt">
{% else %}
{{ 'Alt'|t({}, {'context': 'Alt text in media library'}) }}:
<span>"" ({{ 'Empty'|t({}, {'context': 'Empty alt text in media library'}) }})</span>
</div>
{% endif %}
{% endif %}
</div>
</div>
{% endif %}
</article>
4 changes: 0 additions & 4 deletions translations/fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ msgctxt "Accent color"
msgid "Accent"
msgstr "Korosteväri"

msgctxt "Alt text in media library"
msgid "Alt text"
msgstr "Alt-teksti"

msgctxt "Empty alt text in media library"
msgid "Empty"
msgstr "Tyhjä"
Expand Down
4 changes: 0 additions & 4 deletions translations/sv.po
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
msgid ""
msgstr ""

msgctxt "Alt text in media library"
msgid "Alt text"
msgstr "Alt text"

msgctxt "Empty alt text in media library"
msgid "Empty"
msgstr "Tom"
Expand Down

0 comments on commit 9fe3c25

Please sign in to comment.