hugo-shortcode-gallery icon indicating copy to clipboard operation
hugo-shortcode-gallery copied to clipboard

can resources load remote images url?

Open RandomCivil opened this issue 3 years ago • 6 comments

hi,can resources load remote images url?

RandomCivil avatar Sep 27 '21 01:09 RandomCivil

Hi, i am not sure if I understand your question correctly, but I would answer with "no".

mfg92 avatar Sep 27 '21 21:09 mfg92

hi my resources src is like

---
title: "My First Post"
date: 2021-09-27T08:57:03+08:00
draft: true
albumthumb: "my-first-post/1.png"
resources:
- src: "my-first-post/images/1.png"
- src: "my-first-post/images/2.png"
- src: "https://static.theviper.xyz/images/nginx-ingress-load-balance.png"
---

RandomCivil avatar Sep 28 '21 00:09 RandomCivil

Hello. Is this issue closed? It's not possible to use images from an external resource like a CDN?

sergiosobreira avatar Dec 13 '21 23:12 sergiosobreira

Currently it is not supported to use external images. PR are always welcome, but I guess it is not that easy as hugo would need to download those images during build to create downscaled thumbnails for the gallery.

mfg92 avatar Dec 14 '21 07:12 mfg92

It could work, I have a render hook to work with external images. The following code snippet is an excerpt from my render-image.html:

{{ $image := "" -}}
{{ $lqip := "" -}}
{{ if (urls.Parse .Destination).IsAbs }}
  {{ $image = resources.GetRemote .Destination (dict 
    "body" `{"complete": true}` 
    "headers" (dict 
        "Content-Type" "application/json"
    )
) -}}
{{ else -}}
  {{ $image = .Page.Resources.GetMatch .Destination -}}
{{ end -}}
{{ with $image -}}       
      {{ if or (strings.HasSuffix $image "gif") (strings.HasSuffix $image "svg") }}
        {{ $lqip = $image -}}
      {{- else -}}
        {{ $lqip = $image.Resize site.Params.lqipWidth -}}
      {{ end -}} 

gymnae avatar May 28 '22 20:05 gymnae

I'd just like to ask whether the above query is dead?

It might be a good way to significantly increase the scope of the use case and at the same time increase the robustness of the gallery builds etc.

gvhconnect

gvhconnect avatar May 23 '23 15:05 gvhconnect