mfg92 / hugo-shortcode-gallery

A theme component with a gallery shortcode for the static site generator hugo.
MIT License
348 stars 67 forks source link

can resources load remote images url? #26

Open RandomCivil opened 3 years ago

RandomCivil commented 3 years ago

hi,can resources load remote images url?

mfg92 commented 3 years ago

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

RandomCivil commented 3 years ago

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"
---
sergiosobreira commented 2 years ago

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

mfg92 commented 2 years ago

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.

gymnae commented 2 years ago

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 -}} 
gvhconnect commented 1 year ago

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