diff --git a/exampleSite/assets/images/regular.jpg b/exampleSite/assets/images/regular.jpg new file mode 100644 index 0000000..70a3401 Binary files /dev/null and b/exampleSite/assets/images/regular.jpg differ diff --git a/exampleSite/content/posts/rich-content.md b/exampleSite/content/posts/rich-content.md index b7c896a..81fac33 100644 --- a/exampleSite/content/posts/rich-content.md +++ b/exampleSite/content/posts/rich-content.md @@ -14,6 +14,16 @@ Hugo ships with several [Built-in Shortcodes](https://gohugo.io/content-manageme --- +## Image + +third party image: + +![](https://images.unsplash.com/photo-1662141978148-2eeb2afb3837?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=772&q=80) + +internal image: + +![](images/regular.jpg) + ## YouTube Privacy Enhanced Shortcode {{< youtube ZJthWmvUzzc >}} diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 0fc039c..c4d7497 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,20 +1,26 @@ -{{- $img := .Page.Resources.GetMatch .Destination -}} -{{- if and (not $img) .Page.File -}} - {{ $path := path.Join .Page.File.Dir .Destination }} - {{- $img = resources.Get $path -}} -{{- end -}} - -{{- if $img -}} - {{- if eq $img.MediaType.MainType "video" -}} -
- -
- {{- else -}} - {{ $.Text }} - {{- end -}} +{{- $url := urls.Parse .Destination -}} +{{- if $url.Scheme -}} + {{/* third party image */}} + {{ $.Text }} {{- else -}} - {{- warnf "No image found for %s from %s" .Destination .Page.File }} + {{/* internal image */}} + {{- $img := .Page.Resources.GetMatch .Destination -}} + {{- if not $img -}} + {{- $img = resources.Get .Destination -}} + {{- end -}} + + {{- if $img -}} + {{- if eq $img.MediaType.MainType "video" -}} +
+ +
+ {{- else -}} + {{ $.Text }} + {{- end -}} + {{- else -}} + {{- warnf "No image found for %s from %s" .Destination .Page.File }} + {{- end -}} {{- end -}}