Good ol’ if statements
I used one in the notes template so that animated gifs show properly on the note.
This is because Glide, the library which handles image transformation and asset generation doesn’t support preserving animated gifs. It can do other operations like scaling and cropping, but those would lose all the animated frames.
Here’s what it looks like (disgusting):
{{if note_assets}}
{{note_assets}}
{{ if extension == 'gif' }}
<img src='{{ url }}' class="border-2 border-green-400 p-1" alt="{{ alt | sanitize }}" title="{{ alt | sanitize }}" />
{{ else }}
<img src='{{ glide :src="url" w="1024" }}' class="border-2 border-green-400 p-1" alt="{{ alt | sanitize }}" title="{{ alt | sanitize }}" />
{{ /if }}
{{/note_assets}}
{{ /if }}
#WebDev #Statamic
RE: https://beep.flawbee.net/objects/2dceac0c-681f-433c-afd9-845e5a3bb556