forked from cotes2020/jekyll-theme-chirpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(media): support audio and video tag with multi sources (cotes202…
- Loading branch information
1 parent
b34363d
commit b2bf371
Showing
4 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
- extension: mp3 | ||
mime_type: mpeg | ||
- extension: mov | ||
mime_type: quicktime | ||
- extension: avi | ||
mime_type: x-msvideo | ||
- extension: mkv | ||
mime_type: x-matroska | ||
- extension: ogv | ||
mime_type: ogg | ||
- extension: weba | ||
mime_type: webm | ||
- extension: 3gp | ||
mime_type: 3gpp | ||
- extension: 3g2 | ||
mime_type: 3gpp2 | ||
- extension: mid | ||
mime_type: midi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{% assign src = include.src | strip %} | ||
{% assign title = include.title | strip %} | ||
{% assign types = include.types | default: '' | strip | split: '|' %} | ||
|
||
{% unless src contains '://' %} | ||
{%- capture src -%} | ||
{% include img-url.html src=src %} | ||
{%- endcapture -%} | ||
{% endunless %} | ||
|
||
<p> | ||
<audio class="embed-audio" controls> | ||
{% assign extension = src | split: '.' | last %} | ||
{% assign types = extension | concat: types %} | ||
|
||
{% assign ext_size = extension | size %} | ||
{% assign src_size = src | size %} | ||
{% assign slice_size = src_size | minus: ext_size %} | ||
|
||
{% assign filepath = src | slice: 0, slice_size %} | ||
|
||
{% for type in types %} | ||
{% assign src = filepath | append: type %} | ||
{% assign media_item = site.data.media | find: 'extension', type %} | ||
{% assign mime_type = media_item.mime_type | default: type %} | ||
<source src="{{ src }}" type="audio/{{ mime_type }}"> | ||
{% endfor %} | ||
|
||
Your browser does not support the audio tag. Here is a | ||
<a href="{{ src | strip }}">link to the audio file</a> instead. | ||
</audio> | ||
{% if title %} | ||
<em>{{ title }}</em> | ||
{% endif %} | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters