Last active
June 6, 2019 14:39
-
-
Save ankedsgn/e2f73767223ac240de0a1ec59dbe3c73 to your computer and use it in GitHub Desktop.
Multilanguage alts and titles in Bolt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| in contenttypes.yml: | |
| image: | |
| type: image | |
| attrib: [ alt_nl, title_nl, alt_en, title_en, alt_fr, title_fr ] | |
| in de template: | |
| {% set alt = attribute(record.values.image, 'alt_'~getlanguage() )|default('') %} | |
| {% set title = attribute(record.values.image, 'title_'~getlanguage() )|default('') %} | |
| <figure> | |
| <img src="{{ record.image|image }}" alt="{{ alt }}"/> | |
| {% if title is not empty %}<figcaption>{{ title }}</figcaption>{% endif %} | |
| </figure> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment