From 69fc96ed5bcf36d5c838c933e72fc9fc0c5514a9 Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Tue, 27 May 2025 04:19:51 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20new=20option=20disabl?= =?UTF-8?q?eImageOptimizationMD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exampleSite/config/_default/params.toml | 1 + exampleSite/content/docs/configuration/index.it.md | 3 ++- exampleSite/content/docs/configuration/index.ja.md | 3 ++- exampleSite/content/docs/configuration/index.md | 3 ++- exampleSite/content/docs/configuration/index.zh-cn.md | 3 ++- layouts/_default/_markup/render-image.html | 4 ++-- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 8069e6b7..f07a9502 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -18,6 +18,7 @@ mainSections = ["docs"] # robots = "" disableImageOptimization = false +disableImageOptimizationMD = false disableTextInHeader = false # backgroundImageWidth = 1200 diff --git a/exampleSite/content/docs/configuration/index.it.md b/exampleSite/content/docs/configuration/index.it.md index 4da3babd..fee002c1 100644 --- a/exampleSite/content/docs/configuration/index.it.md +++ b/exampleSite/content/docs/configuration/index.it.md @@ -177,7 +177,8 @@ Many of the article defaults here can be overridden on a per article basis by sp | `showLikes` | _Not set_ | Whether or not articles and list likes are displayed. This requires firebase integrations to be enabled, look below. | | `robots` | _Not set_ | String that indicates how robots should handle your site. If set, it will be output in the page head. Refer to [Google's docs](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives) for valid values. | | `disableImageZoom` | `false` | Disables image zoom feature across all the images in the site. | -| `disableImageOptimization` | `false` | Disables image resize and optimization features across all the images in the site. | +| `disableImageOptimization` | `false` | Disables image resize and optimization features across all the images in the site, except images using markdown syntax (`![](image.jpg)`) | +| `disableImageOptimizationMD` | `false` | Disables image resize and optimization features only for images using markdown syntax (`![](image.jpg)`). | | `disableTextInHeader` | `false` | Disables text in header, useful for logo based headers. | | `defaultBackgroundImage` | _Not set_ | Default background image for both `background` homepage layout and `background` hero style | | `defaultFeaturedImage` | _Not set_ | Default background image for all `featured` images across articles, will be overridden by a local `featured` image. | diff --git a/exampleSite/content/docs/configuration/index.ja.md b/exampleSite/content/docs/configuration/index.ja.md index 0630f6f4..b1471099 100644 --- a/exampleSite/content/docs/configuration/index.ja.md +++ b/exampleSite/content/docs/configuration/index.ja.md @@ -177,7 +177,8 @@ Blowfish は、テーマの機能を制御する多数の設定パラメータ | `showLikes` | _未設定_ | 記事とリストのいいねを表示するかどうかです。これには Firebase 統合を有効にする必要があります。以下をご覧ください。 | | `robots` | _未設定_ | ロボットがサイトをどのように処理するかを示す文字列です。設定されている場合、ページヘッダーに出力されます。有効な値については、[Google のドキュメント](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives)を参照してください。 | | `disableImageZoom` | `false` | サイト内のすべての画像の画像ズーム機能を無効にします。 | -| `disableImageOptimization` | `false` | サイト内のすべての画像の画像サイズ変更と最適化機能を無効にします。 | +| `disableImageOptimization` | `false` | サイト内のすべての画像の画像サイズ変更と最適化機能を無効にします。Markdown 記法(例:`![](image.jpg)`)の画像は対象外です。 | +| `disableImageOptimizationMD` | `false` | Markdown 記法(例:`![](image.jpg)`)の画像の画像サイズ変更と最適化機能のみを無効にします。他の画像には適用されます。 | | `disableTextInHeader` | `false` | ヘッダーのテキストを無効にします。ロゴベースのヘッダーに役立ちます。 | | `defaultBackgroundImage` | _未設定_ | `background` ホームページレイアウトと `background` ヒーロースタイルの両方のデフォルトの背景画像です。 | | `defaultFeaturedImage` | _未設定_ | 記事全体のすべての `featured` 画像のデフォルトの背景画像です。ローカルの `featured` 画像によってオーバーライドされます。 | diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index 6cc76234..9fafbfb1 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -182,7 +182,8 @@ Many of the article defaults here can be overridden on a per article basis by sp | `showLikes` | _Not set_ | Whether or not articles and list likes are displayed. This requires firebase integrations to be enabled, look below. | | `robots` | _Not set_ | String that indicates how robots should handle your site. If set, it will be output in the page head. Refer to [Google's docs](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives) for valid values. | | `disableImageZoom` | `false` | Disables image zoom feature across all the images in the site. | -| `disableImageOptimization` | `false` | Disables image resize and optimization features across all the images in the site. | +| `disableImageOptimization` | `false` | Disables image resize and optimization features across all the images in the site, except images using markdown syntax (`![](image.jpg)`) | +| `disableImageOptimizationMD` | `false` | Disables image resize and optimization features only for images using markdown syntax (`![](image.jpg)`). | | `backgroundImageWidth` | `1200` | Width (in pixels) to scale background images to. | | `disableTextInHeader` | `false` | Disables text in header, useful for logo based headers. | | `defaultBackgroundImage` | _Not set_ | Default background image for both `background` homepage layout and `background` hero style | diff --git a/exampleSite/content/docs/configuration/index.zh-cn.md b/exampleSite/content/docs/configuration/index.zh-cn.md index 12510ba5..9d36cf84 100644 --- a/exampleSite/content/docs/configuration/index.zh-cn.md +++ b/exampleSite/content/docs/configuration/index.zh-cn.md @@ -180,7 +180,8 @@ Blowfish 提供了大量控制主题功能的配置参数,下面的表格中 | `showLikes` | 无 | 是否显示文章和列表页面的点赞量。这需要集成 firebase ,具体可以看下面。 | | `robots` | 无 | 用于支持搜索引擎爬虫如何处理你的网站。如果设置了该值,它将被输出在页面头部。具体的参数值请参考 [Google 文档](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives)。 | | `disableImageZoom` | `false` | 禁用网站上所有图片缩放功能。 | -| `disableImageOptimization` | `false` | 禁用图片上所有图片的调整大小和优化功能。 | +| `disableImageOptimization` | `false` | 禁用图片上所有图片的调整大小和优化功能,使用 Markdown 语法插入的图片(`![](image.jpg)`)除外。 | +| `disableImageOptimizationMD` | `false` | 所有以 Markdown 语法(`![](image.jpg)`)插入的图片,禁用其调整大小和优化功能。 | | `backgroundImageWidth` | `1200` | 宽度(以像素为单位)用于缩放背景图像。 | | `disableTextInHeader` | `false` | 禁用文本类型的标题,对基于 logo 的标题很有用。 | | `defaultBackgroundImage` | 无 | 设置默认背景图,用于 `background` 和 `hero` 布局下的主页。 | diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 74000b80..a60ec1f5 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -20,7 +20,7 @@ {{- end }} {{- end }} -{{- $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} +{{- $disableImageOptimizationMD := .Page.Site.Params.disableImageOptimizationMD | default false }} {{- $url := urls.Parse .Destination }} {{- $altText := .Text }} {{- $caption := .Title }} @@ -36,7 +36,7 @@ {{ template "RenderImageSimple" (dict "src" $url.String "alt" $altText) }} {{- else if $resource }} {{- $isSVG := eq $resource.MediaType.SubType "svg" }} - {{- $shouldOptimize := and (not $disableImageOptimization) (not $isSVG) }} + {{- $shouldOptimize := and (not $disableImageOptimizationMD) (not $isSVG) }} {{- if $shouldOptimize }} {{ template "RenderImageResponsive" (dict "resource" $resource "alt" $altText) }} {{- else }}