{% for source in sources -%} {% set type = source | split(pat=".") | last -%} {% endfor -%} Your browser doesn't support the video tag, which I use in place of .gifs, and/or the video formats in use here – sorry!