Hugo:成像参数不适用于页面捆绑包?

问题描述 投票:0回答:1

我成功地使用了Hugo创建了我的网站,但是我帖子中的图像太大(1.3MB)。

我已经看到有一个

[imaging]

参数可以降低质量,因此我将我的
hugo.toml
配置文件修改为以下
baseURL = 'http://my_beautiful_site/' languageCode = 'en-en' title = 'My Beautiful Site' theme = 'papermod' [imaging] bgColor = '#ffffff' hint = 'photo' quality = 1 resampleFilter = 'Box'

,但是,当我构建网站时,它不会更改图像质量,它只是在
public

文件夹中复制了初始图像。

执行雨果时的日志是:

> rm -rf public/ > hugo --gc .... > hugo Start building sites … hugo v0.134.3-.. BuildDate=2024-09-19T14:28:20Z VendorInfo=snap:0.134.3 WARN deprecated: .Site.Social was deprecated in Hugo v0.124.0 and will be removed in a future release. Use .Site.Params instead. | EN -------------------+----- Pages | 12 Paginator pages | 0 Non-page files | 3 Static files | 0 Processed images | 0 Aliases | 2 Cleaned | 0 Total in 82 ms

我的图像被认为是

Non-page files
,没有
Processed images

我的图像在页面捆绑包中,如Hugo网站的示例所示:
content/
├── my-post/
│   ├── index.md
│   └── my-image.jpg

你知道它可能来自哪里吗?您知道

[imaging]

参数是否适用于页面捆绑图像?
提前感谢您的帮助,

hugo

经过一些研究,似乎

[imaging]

参数不适用于页面捆绑图中的图像。 wo,使用@bogdanoff建议的图像处理功能效果很好。
hugo hugo-content-organization
1个回答
0
投票
的图像的默认渲染挂钩

file

layouts/_default/_markup/render-image.html

{{ $original := .Destination }} {{ $resource := .Page.Resources.GetMatch $original }} {{ if $resource }} {{ $optimized := $resource.Resize "800x webp q75" }} <img src="{{ $optimized.RelPermalink }}" alt="{{ .Text }}"> {{ else }} <img src="{{ $original }}" alt="{{ .Text }}"> {{ end }}

这允许自动调整来自页面捆绑包的图像的大小,并显示其他图像(URL, /static)而不调整大小。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.