Skip to content

Commit 6834509

Browse files
committed
Add YouTube and Vimeo video embed support
1 parent 7dc8953 commit 6834509

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

_includes/vimeo.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{% comment %}
2+
Include Vimeo videos inside your post like so:
3+
{% include vimeo.html id="142316610" aspect="16x9" %}
4+
Note, the aspect ratio is optional (defaults to 16x9).
5+
{% endcomment %}
6+
7+
<div class="embed-responsive aspect-ratio-{{ include.aspect | default: "16x9" }}">
8+
<iframe class="embed-responsive-item" src="https://player.vimeo.com/video/{{ include.id }}" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>
9+
</div>

_includes/youtube.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{% comment %}
2+
Include YouTube videos inside your post like so:
3+
{% include youtube.html id="oHg5SJYRHA0" aspect="4x3" %}
4+
Note, the aspect ratio is optional (defaults to 16x9).
5+
{% endcomment %}
6+
7+
<div class="embed-responsive aspect-ratio-{{ include.aspect | default: "16x9" }}">
8+
<iframe class="embed-responsive-item" width="560" height="315" src="https://www.youtube-nocookie.com/embed/{{ include.id }}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
9+
</div>

assets/_sass/utilities/_embeds.scss

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
////////////////////
2+
// Responsive Embeds
3+
////////////////////
4+
5+
.embed-responsive {
6+
position: relative;
7+
display: block;
8+
height: 0;
9+
padding: 0;
10+
overflow: hidden;
11+
12+
.embed-responsive-item,
13+
iframe,
14+
embed,
15+
object,
16+
video {
17+
position: absolute;
18+
top: 0;
19+
left: 0;
20+
bottom: 0;
21+
height: 100%;
22+
width: 100%;
23+
border: 0;
24+
}
25+
}
26+
27+
// Aspect ratios
28+
.aspect-ratio-1x1 {
29+
padding-top: 100%;
30+
}
31+
32+
.aspect-ratio-16x9 {
33+
padding-top: 56.25%;
34+
}
35+
36+
.aspect-ratio-4x3 {
37+
padding-top: 75%;
38+
}

assets/css/main.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
@import "utilities/spacing";
2323
@import "utilities/images";
2424
@import "utilities/position";
25+
@import "utilities/embeds";
2526

2627
@import "component/button";
2728
@import "component/navigation";

0 commit comments

Comments
 (0)