Skip to content

引用于 cdn 的图片 没法生成图册吗? #659

Answered by GHJayce
taurusxin asked this question in Q&A
Discussion options

You must be logged in to vote

外链图片的问题已经解决,在保持原有功能的基础上仅新增了对外链图片的支持,需要修改的文件不多。

经过测试,hugo serverhugo命令执行以后的效果均表现正常,因为是外链,所以会对首次启动有一些影响。

详细过程都在Hugo Theme Stack图库是怎么工作的?怎样才能支持外链图片?这篇文章里了,感兴趣的话可以看下。


改动的文件如下:

1、layouts/_default/_markup/render-image.html

{{- $Permalink := .Destination | safeURL -}}
{{- $image := "" -}}

{{- if and (hasPrefix $Permalink "http") (default false .Page.Site.Params.render.image.externalLink.enabled) -}}
	{{- with resources.GetRemote $Permalink -}}
		{{- with .Err -}}
			{{- $warnMsg := printf "%s" $Permalink -}}
			{{- warnf "%s.\nPlease check the link: %s\n" . $warnMsg -}}
		{{- else -}}
			{{- $image = . -}}
		{{- end -}}
	{{- else -}}
	  {{- warnf "Unable to get remote resource %q" $Permalink …

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
1 reply
@mpv945
Comment options

Comment options

You must be logged in to vote
5 replies
@GHJayce
Comment options

@GHJayce
Comment options

@Lovirr
Comment options

@mpv945
Comment options

@GHJayce
Comment options

Comment options

You must be logged in to vote
4 replies
@Lovirr
Comment options

@taurusxin
Comment options

@GHJayce
Comment options

@GHJayce
Comment options

Answer selected by taurusxin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants