mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Add an iFrame title to the YouTube shortcode
To accommodate modern web accessibility as outlined here https://dequeuniversity.com/tips/provide-iframe-titles
This commit is contained in:
parent
07f6e1499c
commit
919bc9210a
2 changed files with 7 additions and 7 deletions
|
@ -202,17 +202,17 @@ func TestShortcodeYoutube(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
`{{< youtube w7Ft2ymGmfc >}}`,
|
`{{< youtube w7Ft2ymGmfc >}}`,
|
||||||
"(?s)\n<div style=\".*?\">.*?<iframe src=\"//www.youtube.com/embed/w7Ft2ymGmfc\" style=\".*?\" allowfullscreen frameborder=\"0\">.*?</iframe>.*?</div>\n",
|
"(?s)\n<div style=\".*?\">.*?<iframe src=\"//www.youtube.com/embed/w7Ft2ymGmfc\" style=\".*?\" allowfullscreen frameborder=\"0\" title=\"YouTube Video\">.*?</iframe>.*?</div>\n",
|
||||||
},
|
},
|
||||||
// set class
|
// set class
|
||||||
{
|
{
|
||||||
`{{< youtube w7Ft2ymGmfc video>}}`,
|
`{{< youtube w7Ft2ymGmfc video>}}`,
|
||||||
"(?s)\n<div class=\"video\">.*?<iframe src=\"//www.youtube.com/embed/w7Ft2ymGmfc\" allowfullscreen frameborder=\"0\">.*?</iframe>.*?</div>\n",
|
"(?s)\n<div class=\"video\">.*?<iframe src=\"//www.youtube.com/embed/w7Ft2ymGmfc\" allowfullscreen frameborder=\"0\" title=\"YouTube Video\">.*?</iframe>.*?</div>\n",
|
||||||
},
|
},
|
||||||
// set class and autoplay (using named params)
|
// set class and autoplay (using named params)
|
||||||
{
|
{
|
||||||
`{{< youtube id="w7Ft2ymGmfc" class="video" autoplay="true" >}}`,
|
`{{< youtube id="w7Ft2ymGmfc" class="video" autoplay="true" >}}`,
|
||||||
"(?s)\n<div class=\"video\">.*?<iframe src=\"//www.youtube.com/embed/w7Ft2ymGmfc\\?autoplay=1\".*?allowfullscreen frameborder=\"0\">.*?</iframe>.*?</div>",
|
"(?s)\n<div class=\"video\">.*?<iframe src=\"//www.youtube.com/embed/w7Ft2ymGmfc\\?autoplay=1\".*?allowfullscreen frameborder=\"0\" title=\"YouTube Video\">.*?</iframe>.*?</div>",
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -39,11 +39,11 @@ func (t *templateHandler) embedShortcodes() {
|
||||||
t.addInternalShortcode("speakerdeck.html", "<script async class='speakerdeck-embed' data-id='{{ index .Params 0 }}' data-ratio='1.33333333333333' src='//speakerdeck.com/assets/embed.js'></script>")
|
t.addInternalShortcode("speakerdeck.html", "<script async class='speakerdeck-embed' data-id='{{ index .Params 0 }}' data-ratio='1.33333333333333' src='//speakerdeck.com/assets/embed.js'></script>")
|
||||||
t.addInternalShortcode("youtube.html", `{{ if .IsNamedParams }}
|
t.addInternalShortcode("youtube.html", `{{ if .IsNamedParams }}
|
||||||
<div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}>
|
<div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}>
|
||||||
<iframe src="//www.youtube.com/embed/{{ .Get "id" }}?{{ with .Get "autoplay" }}{{ if eq . "true" }}autoplay=1{{ end }}{{ end }}"
|
<iframe src="//www.youtube.com/embed/{{ .Get "id" }}?{{ with .Get "autoplay" }}{{ if eq . "true" }}autoplay=1{{ end }}{{ end }}"
|
||||||
{{ if not (.Get "class") }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}allowfullscreen frameborder="0"></iframe>
|
{{ if not (.Get "class") }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}allowfullscreen frameborder="0" title="YouTube Video"></iframe>
|
||||||
</div>{{ else }}
|
</div>{{ else }}
|
||||||
<div {{ if len .Params | eq 2 }}class="{{ .Get 1 }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}>
|
<div {{ if len .Params | eq 2 }}class="{{ .Get 1 }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}>
|
||||||
<iframe src="//www.youtube.com/embed/{{ .Get 0 }}" {{ if len .Params | eq 1 }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}allowfullscreen frameborder="0"></iframe>
|
<iframe src="//www.youtube.com/embed/{{ .Get 0 }}" {{ if len .Params | eq 1 }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}allowfullscreen frameborder="0" title="YouTube Video"></iframe>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}`)
|
{{ end }}`)
|
||||||
t.addInternalShortcode("vimeo.html", `{{ if .IsNamedParams }}<div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}>
|
t.addInternalShortcode("vimeo.html", `{{ if .IsNamedParams }}<div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}>
|
||||||
|
@ -139,7 +139,7 @@ func (t *templateHandler) embedTemplates() {
|
||||||
{{ $right := sub .TotalPages .PageNumber }}
|
{{ $right := sub .TotalPages .PageNumber }}
|
||||||
{{ $showNumber := or (le .PageNumber 3) (eq $right 0) }}
|
{{ $showNumber := or (le .PageNumber 3) (eq $right 0) }}
|
||||||
{{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }}
|
{{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }}
|
||||||
{{ if $showNumber }}
|
{{ if $showNumber }}
|
||||||
{{ $.Scratch.Set "__paginator.ellipsed" false }}
|
{{ $.Scratch.Set "__paginator.ellipsed" false }}
|
||||||
{{ $.Scratch.Set "__paginator.shouldEllipse" false }}
|
{{ $.Scratch.Set "__paginator.shouldEllipse" false }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
|
Loading…
Reference in a new issue