diff --git a/exampleSite/content/post/image-process/images/hugo-logo-wide.svg b/exampleSite/content/post/image-process/images/hugo-logo-wide.svg new file mode 100644 index 0000000..1f6a79e --- /dev/null +++ b/exampleSite/content/post/image-process/images/hugo-logo-wide.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/exampleSite/content/post/image-process/index.md b/exampleSite/content/post/image-process/index.md index 572671a..e6131b3 100644 --- a/exampleSite/content/post/image-process/index.md +++ b/exampleSite/content/post/image-process/index.md @@ -5,6 +5,7 @@ date = "2023-12-01" description = "Demo of Hugo's image processing" tags = [] toc = false +image = "images/hugo-logo-wide.svg" +++ ![Photo by Behnam Norouzi on Unsplash](./images/behnam-norouzi-_1ok63FFlM4-unsplash.jpg "Photo by Behnam Norouzi on Unsplash") diff --git a/exampleSite/content/post/image-process/index.zh-cn.md b/exampleSite/content/post/image-process/index.zh-cn.md index 10b98da..3ab601c 100644 --- a/exampleSite/content/post/image-process/index.zh-cn.md +++ b/exampleSite/content/post/image-process/index.zh-cn.md @@ -5,6 +5,7 @@ date = "2023-12-01" description = "关于Hugo中图片处理的示例" tags = [] toc = false +image = "images/hugo-logo-wide.svg" +++ ![Photo by Behnam Norouzi on Unsplash](./images/behnam-norouzi-_1ok63FFlM4-unsplash.jpg "Photo by Behnam Norouzi on Unsplash") diff --git a/layouts/partials/block/image.html b/layouts/partials/block/image.html index 69c14f9..216964a 100644 --- a/layouts/partials/block/image.html +++ b/layouts/partials/block/image.html @@ -8,6 +8,14 @@ {{- $dest = path.Join (path.Dir $dest) (path.Base $dest) -}} {{- with .Resources.Get $dest -}} + {{- if eq .MediaType.SubType "svg" -}} +
+ {{ $alt }} +
+ {{- else -}} {{- $src := . -}} {{- $dataSzes := "(min-width: 1024px) 100vw, 50vw" -}} {{- $actualImg := $src.Resize (print "640x jpg " $filter) -}} @@ -30,6 +38,7 @@ {{- end -}}" sizes="{{ $dataSzes }}" /> {{ $alt }} + {{- end -}} {{- else -}}