Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added video embedding #103

Merged
merged 5 commits into from
May 29, 2023
Merged

added video embedding #103

merged 5 commits into from
May 29, 2023

Conversation

iamcool0090
Copy link
Contributor

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.
media object

@knadh knadh self-assigned this May 27, 2023
@knadh
Copy link
Owner

knadh commented May 28, 2023

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 %}

@iamcool0090
Copy link
Contributor Author

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

@iamcool0090
Copy link
Contributor Author

{% 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 %}

@knadh knadh merged commit 9508ac0 into knadh:master May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants