Commit e41eb036 authored by CSA's avatar CSA
Browse files

Youtube shortcode now expects file locally

parent 0f15bd19
{{ $api := "http://noapi.lan" }}
{{ if eq (len .Params) 2 }}{{ .Scratch.Set "width" (.Get 1) }}{{ else }}{{ .Scratch.Set "width" "512" }}{{ end }}
{{ if eq (len .Params) 3 }}{{ .Scratch.Set "quality" (.Get 2) }}{{ else }}{{ .Scratch.Set "quality" "30" }}{{ end }}
{{ $width := .Scratch.Get "width" }}
{{ $quality := .Scratch.Get "quality" }}
{{ $id := .Get 0 }}
{{ $request := printf "%s/youtube/preview/%s/%s/%s" $api $id $width $quality }}
{{ $result := getJSON $request }}
{{ if eq $result.status "ok" }}
<div style="overflow: hidden;">
<style scoped="scoped">
div { background: url('data:image/jpeg;base64,{{ $result.content.image64 | safeCSS }}');
background-size: cover; background-repeat: no-repeat; text-align: center; box-shadow: inset 0 0 10px #000000; margin: 1rem auto;
width: 100%; max-height: {{ $result.content.previewDim.h }}px;
}
@media screen and (min-width: {{ $result.content.previewDim.w | safeCSS }}px) {
div { max-width: {{ $result.content.previewDim.w | safeCSS }}px; height: {{ $result.content.previewDim.h | safeCSS }}px; }
img { position: relative; top: 50%; transform: translateY(-50%); margin: auto auto; }
}
</style>
<a href="https://youtube.com/watch?v={{ $id }}"><img alt="Play video in a new tab" src="{{ "/images/widgets/play-btn.png" | relURL }}"></a>
</div>
{{ end }}
<div style="position:relative;">
<style scoped="scoped">
a {
display: block; position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
z-index: 1;
background: url('/images/widgets/play-btn.png') no-repeat center center;
background-size: 20%;
}
img {
display: block; margin: auto; max-width: 100%;
}
</style>
<img src="{{ printf "/external/youtube/%s.jpg" $id | relURL }}" alt="Youtube thumbnail {{ $id }}">
<a href="https://youtube.com/watch?v={{ $id }}"></a>
</div>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment