Closed iamcool0090 closed 1 year ago
Thanks @iamcool0090. I think this can be simplified into something like this. Could you please test and see if this works?
{% set ext = {{ m.media.url.split('/')[-1].split('.')[-1] }} %}
{% if is in(ext, ['mp4', 'webm', 'ogg', 'ogv', 'mov']) %}
<video width="100%" height="100%" controls>
<source src="{{ config.media_dir }}/{{ m.media.url }}">
</video>
<a href="{{ config.media_dir }}/{{ m.media.url }}">{{ m.media.title }}</a>
{% else %}
<a href="{{ config.media_dir }}/{{ m.media.url }}">
<img src="{{ config.media_dir }}/{{ m.media.thumb }}" class="thumb" /><br />
<span class="filename">{{ m.media.title }}</span>
</a>
{% endif %}
Yes this way of comparing the media extension with a set of media extensions is a better approach. Changed some part of the code you provided.
It's working perfectly
Thank You
{% set ext = m.media.url.split('/')[-1].split('.')[-1] %}
{% if ext in ['mp4', 'webm', 'ogg', 'ogv', 'mov'] %}
<video width="100%" height="100%" controls>
<source src="{{ config.media_dir }}/{{ m.media.url }}">
</video>
<a href="{{ config.media_dir }}/{{ m.media.url }}">{{ m.media.title }}</a>
{% else %}
<a href="{{ config.media_dir }}/{{ m.media.url }}">
<img src="{{ config.media_dir }}/{{ m.media.thumb }}" class="thumb" /><br />
<span class="filename">{{ m.media.title }}</span>
</a>
{% endif %}
for some reason the media.type is 'photo' for a video object( '.mp4' ) so used this method of identification of video files by comparing file extension against a list of video extensions.