Skip to content

Instantly share code, notes, and snippets.

@ankedsgn
Last active June 6, 2019 14:39
Show Gist options
  • Select an option

  • Save ankedsgn/e2f73767223ac240de0a1ec59dbe3c73 to your computer and use it in GitHub Desktop.

Select an option

Save ankedsgn/e2f73767223ac240de0a1ec59dbe3c73 to your computer and use it in GitHub Desktop.
Multilanguage alts and titles in Bolt
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