mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-29 03:53:30 +08:00
Support External images gallery.
This commit is contained in:
parent
21da06e448
commit
2c01c82e80
@ -26,6 +26,12 @@ categories:
|
|||||||
|
|
||||||
## 图片
|
## 图片
|
||||||
|
|
||||||
|
External images:
|
||||||
|
|
||||||
|
 
|
||||||
|
|
||||||
|
Internal images:
|
||||||
|
|
||||||
 
|
 
|
||||||
|
|
||||||
 
|
 
|
||||||
|
@ -1,5 +1,23 @@
|
|||||||
{{- $image := .Page.Resources.GetMatch (printf "%s" (.Destination | safeURL)) -}}
|
|
||||||
{{- $Permalink := .Destination | relURL | safeURL -}}
|
{{- $Permalink := .Destination | relURL | safeURL -}}
|
||||||
|
{{- $image := "" -}}
|
||||||
|
|
||||||
|
{{- if hasPrefix $Permalink "http" -}}
|
||||||
|
{{- with resources.GetRemote $Permalink -}}
|
||||||
|
{{- with .Err -}}
|
||||||
|
{{- $warnMsg := printf "%s" $Permalink -}}
|
||||||
|
{{- warnf "%s.\nPlease check the link: %s\n" . $warnMsg -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $image = resources.GetRemote $Permalink -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- errorf "Unable to get remote resource %q" $Permalink -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $image := .Page.Resources.GetMatch (printf "%s" (.Destination | safeURL)) -}}
|
||||||
|
{{- if $image -}}
|
||||||
|
{{- $Permalink = $image.RelPermalink -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
{{- $alt := .PlainText | safeHTML -}}
|
{{- $alt := .PlainText | safeHTML -}}
|
||||||
{{- $Width := 0 -}}
|
{{- $Width := 0 -}}
|
||||||
{{- $Height := 0 -}}
|
{{- $Height := 0 -}}
|
||||||
@ -10,7 +28,6 @@
|
|||||||
|
|
||||||
{{- if $image -}}
|
{{- if $image -}}
|
||||||
{{- $notSVG := ne (path.Ext .Destination) ".svg" -}}
|
{{- $notSVG := ne (path.Ext .Destination) ".svg" -}}
|
||||||
{{- $Permalink = $image.RelPermalink -}}
|
|
||||||
|
|
||||||
{{- if $notSVG -}}
|
{{- if $notSVG -}}
|
||||||
{{- $Width = $image.Width -}}
|
{{- $Width = $image.Width -}}
|
||||||
|
Loading…
Reference in New Issue
Block a user