File tree Expand file tree Collapse file tree 5 files changed +82
-10
lines changed
Expand file tree Collapse file tree 5 files changed +82
-10
lines changed Original file line number Diff line number Diff line change 11< iframe
2- class ="embed-video bilibili "
2+ class ="embed-video "
33 loading ="lazy "
44 src ="https://player.bilibili.com/player.html?bvid={{ include.id }} "
55 scrolling ="no "
6- border ="0 "
7- frameborder ="no "
6+ frameborder ="0 "
87 framespacing ="0 "
98 allowfullscreen ="true "
10- > </ iframe >
9+ > </ iframe >
Original file line number Diff line number Diff line change 1+ {% assign video_url = include.src %}
2+ {% assign poster_url = include.poster %}
3+
4+ {% unless video_url contains '://' %}
5+ {%- capture video_url -%}
6+ {% include img-url.html src=video_url img_path=page.img_path %}
7+ {%- endcapture -%}
8+ {% endunless %}
9+
10+ {% if poster_url %}
11+ {% unless poster_url contains '://' %}
12+ {%- capture poster_url -%}
13+ {% include img-url.html src=poster_url img_path=page.img_path %}
14+ {%- endcapture -%}
15+ {% endunless %}
16+ {% assign poster = 'poster="' | append: poster_url | append: '"' %}
17+ {% endif %}
18+
19+ {% assign attributes = 'controls' %}
20+
21+ {% if include.autoplay %}
22+ {% assign attributes = attributes | append: ' ' | append: 'autoplay' %}
23+ {% endif %}
24+
25+ {% if include.loop %}
26+ {% assign attributes = attributes | append: ' ' | append: 'loop' %}
27+ {% endif %}
28+
29+ {% if include.muted %}
30+ {% assign attributes = attributes | append: ' ' | append: 'muted' %}
31+ {% endif %}
32+
33+ < p >
34+ < video class ="embed-video file " src ="{{ video_url }} " {{ poster }} {{ attributes }} >
35+ Your browser doesn't support HTML video. Here is a < a href ="{{ url }} "> link to the video</ a > instead.
36+ </ video >
37+ < em > {{ include.title }}</ em >
38+ </ p >
Original file line number Diff line number Diff line change 11< iframe
2- class ="embed-video youtube "
2+ class ="embed-video "
33 loading ="lazy "
44 src ="https://www.youtube.com/embed/{{ include.id }} "
55 title ="YouTube video player "
Original file line number Diff line number Diff line change @@ -427,6 +427,8 @@ Or adding `render_with_liquid: false` (Requires Jekyll 4.0 or higher) to the pos
427427
428428# # Videos
429429
430+ # ## Video Sharing Platform
431+
430432You can embed a video with the following syntax :
431433
432434` ` ` liquid
@@ -443,6 +445,31 @@ The following table shows how to get the two parameters we need in a given video
443445| [https://www.**twitch**.tv/videos/**1634779211**](https://www.twitch.tv/videos/1634779211) | `twitch` | `1634779211` |
444446| [https://www.**bilibili**.com/video/**BV1Q44y1B7Wf**](https://www.bilibili.com/video/BV1Q44y1B7Wf) | `bilibili` | `BV1Q44y1B7Wf` |
445447
448+ # ## Video File
449+
450+ If you want to embed a video file directly, use the following syntax :
451+
452+ ` ` ` liquid
453+ {% include embed/video.html src='{URL}' %}
454+ ` ` `
455+
456+ Where `URL` is an URL to a video file e.g. `/assets/img/sample/video.mp4`.
457+
458+ You can also specify additional attributes for the embedded video file. Here is a full list of attributes allowed.
459+
460+ - ` poster='/path/to/poster.png'` - poster image for a video that is shown while video is downloading
461+ - ` title='Text'` - title for a video that appears below the video and looks same as for images
462+ - ` autoplay=true` - video automatically begins to play back as soon as it can
463+ - ` loop=true` - automatically seek back to the start upon reaching the end of the video
464+ - ` muted=true` - audio will be initially silenced
465+
466+ Consider an example utilizing all of the above :
467+
468+ ` ` ` liquid
469+ {% include embed/video.html src='video.mp4' poster='poster.png' title='Demo video'
470+ autoplay=true loop=true muted=true %}
471+ ` ` `
472+
446473# # Learn More
447474
448475For more knowledge about Jekyll posts, visit the [Jekyll Docs : Posts](https://jekyllrb.com/docs/posts/).
Original file line number Diff line number Diff line change @@ -550,17 +550,25 @@ main {
550550 width : 100% ;
551551 height : 100% ;
552552 margin-bottom : 1rem ;
553+ aspect-ratio : 16 / 9 ;
553554
554555 @extend %rounded ;
555556
556- & .youtube ,
557- & .bilibili {
558- aspect-ratio : 16 / 9 ;
559- }
560-
561557 & .twitch {
562558 aspect-ratio : 310 / 189 ;
563559 }
560+
561+ & .file {
562+ display : block ;
563+ width : auto ;
564+ height : auto ;
565+ max-width : 100% ;
566+ max-height : 100% ;
567+ margin : auto ;
568+ margin-bottom : 0 ;
569+ }
570+
571+ @extend %img-caption ;
564572}
565573
566574/* --- buttons --- */
You can’t perform that action at this time.
0 commit comments