YouTube embed too small #2683
Unanswered
liberomureddu
asked this question in
Q&A
Replies: 1 comment 2 replies
-
I worked a bit more on the YouTube embed solution, and it seems it work well:
code.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
}
.embed-container iframe,
.embed-container object,
.embed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
code{% assign extension = include.path | split: '.' | last %}
<figure class="embed-container">
{% if extension == 'mp4' or extension == 'webm' or extension == 'ogg' %}
<video
src="{% if include.cache_bust %}{{ include.path | relative_url | bust_file_cache }}{% else %}{{ include.path | relative_url }}{% endif %}"
{% if include.class %}
class="{{ include.class }}"
{% endif %}
{% if include.width %}
width="{{ include.width }}"
{% else %}
width="auto"
{% endif %}
{% if include.height %}
height="{{ include.height }}"
{% else %}
height="auto"
{% endif %}
{% if include['min-width'] %}
min-width="{{ include.min-width }}"
{% endif %}
{% if include['min-height'] %}
min-height="{{ include.min-height }}"
{% endif %}
{% if include['max-width'] %}
max-width="{{ include.max-width }}"
{% endif %}
{% if include['max-height'] %}
height="{{ include.max-height }}"
{% endif %}
{% if include.title %}
title="{{ include.title }}"
{% endif %}
{% if include.alt %}
alt="{{ include.alt }}"
{% endif %}
{% if include.autoplay %}
autoplay
{% endif %}
{% if include.controls %}
controls
{% endif %}
{% if include.loop %}
loop
{% endif %}
{% if include.muted %}
muted
{% endif %}
{% if include.poster %}
poster="{{ include.poster }}"
{% endif %}
/>
{% else %}
<iframe
src="{{ include.path }}"
{% if include.class %}
class="{{ include.class }}"
{% endif %}
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen
{% if include.width %}
width="{{ include.width }}"
{% else %}
width="100%"
{% endif %}
{% if include.height %}
height="{{ include.height }}"
{% else %}
height="100%"
{% endif %}
{% if include['min-width'] %}
min-width="{{ include.min-width }}"
{% endif %}
{% if include['min-height'] %}
min-height="{{ include.min-height }}"
{% endif %}
{% if include['max-width'] %}
max-width="{{ include.max-width }}"
{% endif %}
{% if include['max-height'] %}
height="{{ include.max-height }}"
{% endif %}
{% if include.alt %}
alt="{{ include.alt }}"
{% endif %}
{% if include.title %}
title="{{ include.title }}"
{% endif %}
/>
{% endif %}
{% if include.caption %}
<figcaption class="caption">{{ include.caption }}</figcaption>
{% endif %}
</figure> Everything seems to work, but it'd be great to hear the opinion of more experienced people. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everybody!
First post here, and I wanted to thank all the people who have made this wonderful theme!
I have a question about embedding YouTube videos.
I used the code as in here
but the resulting embedded video is too small. Moreover its upper and lower borders are slightly cropped. I tried to add width and height, played with column sizes, edited the css directly in the browser, but I haven't found any solution.
I then added to my page the code found here, and it works fine.
However, I would like to be able to have a grid of YouTube videos, something I cannot do anymore with this workaround.
Any suggestion?
Thank you in advance for your time.
Beta Was this translation helpful? Give feedback.
All reactions