jekyll-auto-thumbnails 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e9c5ede1e1900fe3074040b44f1566cd3b697068f2e580d4a1087896692533c
4
- data.tar.gz: 4514e267830f68e4b881fdf0bfffbcdd882e8211d199d6e702b4314750159d3f
3
+ metadata.gz: 546393752a2bbd53df36203bf7868325fb22b4f4bf67b9dfd607ceeba1e065ba
4
+ data.tar.gz: 256c67cec473e8142db69613658dd6b5ae527d1b8093fe5677b80cea9ac021a2
5
5
  SHA512:
6
- metadata.gz: 1313ca36c9f012d43a1e26b17308607293ac4a536f22f4186f3f8690934b30cdb3c5549db96ce27549c55062ba090744d770828ff62f235bb2ef804b20192b25
7
- data.tar.gz: ad178e312f32bc8511a2a42dba2b5fbd31bd96e24acc8ffe2e37fb6ad3dbabba189aaca0efaaddcdd3b91726dcc17cfe95c6284d28854e9377cb91c72ab1afac
6
+ metadata.gz: fbe3f35ac23fce623905aa5edf3d47c301677da85c38915d4dd8e2e46f0d35a750e15c47ae71cdfe405023c044bfca4c6848d6a1acdd96228cecbb5422d57d31
7
+ data.tar.gz: b8d9c4d046f6a75bc6ccb5484ad53971730cd2b681b223fb94dff31334090f9c52df5da7cbefab9ae48fb749f87f079e7b25152b43b74ea6db7b7273140513f6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.2.2](https://github.com/Texarkanine/jekyll-auto-thumbnails/compare/v2.2.1...v2.2.2) (2026-11-28)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * keep article image ratio when the column shrinks ([#74](https://github.com/Texarkanine/jekyll-auto-thumbnails/issues/74)) ([e30d5bc](https://github.com/Texarkanine/jekyll-auto-thumbnails/commit/e30d5bc24b65bd5d8ddc06c9b939cbbdda6eeca4))
9
+
3
10
  ## [2.2.1](https://github.com/Texarkanine/jekyll-auto-thumbnails/compare/v2.2.0...v2.2.1) (2026-11-23)
4
11
 
5
12
 
data/README.md CHANGED
@@ -69,7 +69,7 @@ Pages that contain no replaceable `<article><img>` are no longer re-serialized a
69
69
  - Images with `width` or `height` attributes → uses those dimensions
70
70
  - Unsized images exceeding max config → thumbnails to max dimensions
71
71
  3. **Generation**: Creates thumbnails with MD5-based caching in `.jekyll-cache/`
72
- 4. **Rewrite**: Points `<img src>` at a thumbnail when one was made, and writes `width` and `height` for the file the browser will load. A measured image whose `src` does not change still gets both numbers.
72
+ 4. **Rewrite**: Points `<img src>` at a thumbnail when one was made, and writes `width` and `height` for the file the browser will load. A measured image whose `src` does not change still gets both numbers. A changed page also gets `<style>@layer{:where(article img){height:auto}}</style>` in `<head>`, because the `width` and `height` attributes also set a CSS height, and `height: auto` keeps a theme with `max-width: 100%` from stretching the picture.
73
73
  5. **File Copying**: Copies thumbnails to `_site/` after build
74
74
 
75
75
  ## Usage Examples
@@ -106,6 +106,9 @@ Works automatically with any Markdown processor, because it checks the rendered
106
106
  ![Photo](photo.jpg) <!-- Auto-detects size -->
107
107
  ```
108
108
 
109
+ ## Narrow columns
110
+
111
+ The `width` and `height` attributes keep the image's shape, and they also set a CSS height. The style sets `height: auto`, so a theme with `max-width: 100%` does not stretch the picture. Your own CSS `height` still wins, including a height declared in `@layer`. The style is absent when the page is not rewritten, when the page has no `head`, or when the browser ignores `:where()`.
109
112
 
110
113
  ## Cache Behavior
111
114
 
@@ -5,6 +5,10 @@ require_relative "html_parser"
5
5
  module JekyllAutoThumbnails
6
6
  # Jekyll hook integration
7
7
  module Hooks
8
+ # Anonymous layer, declared first. Beats the height attribute.
9
+ # Loses to a later author layer and to unlayered author height.
10
+ ARTICLE_IMAGE_HEIGHT_RULE = "@layer{:where(article img){height:auto}}"
11
+
8
12
  # Format a duration for Jekyll log suffixes.
9
13
  #
10
14
  # @param seconds [Numeric] elapsed seconds
@@ -181,8 +185,30 @@ module JekyllAutoThumbnails
181
185
  end
182
186
  end
183
187
 
184
- modified ? doc.to_html : html
188
+ return html unless modified
189
+
190
+ release_article_image_height(doc)
191
+ doc.to_html
192
+ end
193
+
194
+ def self.release_article_image_height(doc)
195
+ return if article_image_height_rule?(doc)
196
+
197
+ head = doc.at_css("head")
198
+ return unless head
199
+
200
+ style = doc.create_element("style")
201
+ style.content = ARTICLE_IMAGE_HEIGHT_RULE
202
+ head.prepend_child(style)
203
+ end
204
+
205
+ def self.article_image_height_rule?(doc)
206
+ needle = ARTICLE_IMAGE_HEIGHT_RULE.gsub(/\s+/, "")
207
+ doc.css("style").any? do |node|
208
+ node.content.gsub(/\s+/, "").include?(needle)
209
+ end
185
210
  end
211
+ private_class_method :release_article_image_height, :article_image_height_rule?
186
212
 
187
213
  # Check if a document outputs HTML (not CSS, JS, etc.)
188
214
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllAutoThumbnails
4
- VERSION = "2.2.1"
4
+ VERSION = "2.2.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-auto-thumbnails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Texarkanine