Skip to content

Commit 07049da

Browse files
author
Ben Zörb
authored
Merge pull request #55 from jungvonmatt/feat/improve-vimeo-template
Do not throw on invalid Vimeo id, render hint instead
2 parents f073392 + 5f07ed6 commit 07049da

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

templates/app/config/_default/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ disableHugoGeneratorInject: true
77
enableRobotsTXT: true
88
buildDrafts: true
99
languageCode: en
10+
ignoreErrors:
11+
- error-remote-getjson
1012
defaultContentLanguage: en
1113
defaultContentLanguageInSubdir: true
1214
sitemap:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
buildDrafts: false
2+
ignoreErrors:
3+
- error-remote-getjson

templates/theme-default/layouts/partials/components/c-video/embed-vimeo.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@
6363
{{/* Build player url */}}
6464
{{- $url := print "https://player.vimeo.com/video/" $video_id "?" (delimit $query "&") -}}
6565

66-
{{/* Try to fetch thumbnail & title from vimeo oembed json */}}
66+
{{/* Try getting thumbnail & title from Vimeo oEmbed endpoint */}}
6767
{{- $poster_src := "" -}}
68+
6869
{{- with getJSON "https://vimeo.com/api/oembed.json?url=https://vimeo.com/" $video_id }}
69-
{{/* Try get with & height from oembed to scale the thumbnail */}}
70+
{{/* Access width & height from Vimeo embedcode to scale the thumbnail */}}
7071
{{- $width := 0 -}}
7172
{{- $height := 0 -}}
7273
{{- $factor := 0 -}}
@@ -87,7 +88,11 @@
8788
{{- with .title -}}
8889
{{- $title = $title | default . -}}
8990
{{- end -}}
90-
{{- end -}}
91+
{{ else }}
92+
{{/* Generate Embedcode failed, possibly due to invalid Vimeo source URL */}}
93+
{{ warnf "Generating Vimeo embedcode failed" }}
94+
<div>Generating Vimdeo embedcode failed. Please make sure to use a valid source URL.</div>
95+
{{ end }}
9196

9297
{{/* Generate srcdoc iframe placholder when autoplay is not enabled */}}
9398
{{- $srcdoc := false -}}

0 commit comments

Comments
 (0)