Skip to content

Instantly share code, notes, and snippets.

@WilliamIsted
Last active April 3, 2019 22:38
Show Gist options
  • Save WilliamIsted/86a81afdd911cd676f9173609571e65a to your computer and use it in GitHub Desktop.
Save WilliamIsted/86a81afdd911cd676f9173609571e65a to your computer and use it in GitHub Desktop.
Craft CMS - Show image alt text if it has been set and isn't autogenerated
<img{% if image.title | kebab != image.slug %} alt="{{ image.title }}"{% endif %} src="{{ image.getUrl('thumb') }}">
Example Usage:
{% if entry.images | length %}
{% for image in entry.images %}
<img{% if image.title | kebab != image.slug %} alt="{{ image.title }}"{% endif %} src="{{ image.getUrl('thumb') }}">
{% endfor %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment