jekyll_img 0.2.8 → 0.2.9
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 +4 -4
- data/.rubocop.yml +2 -2
- data/CHANGELOG.md +10 -0
- data/README.md +9 -3
- data/lib/img_builder.rb +6 -4
- data/lib/img_props.rb +26 -4
- data/lib/jekyll_img/version.rb +1 -1
- data/lib/jekyll_img.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fceb334580b84bf7a4238093ab6fb718d1b5fc84a087b1f554764be2ddae477
|
4
|
+
data.tar.gz: b0a489a01ee502e0bb4c6006610a8d82faf3561086fa4f57ce752158e0b9770a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14a147fe5e8ee74caffa3c4919d31fc28389ed9c4d5571357fc4797f1efaba10960eb2cefe9a3ebc68a85e76a339acdc9916d1191df11a2f9d1381412fff085a
|
7
|
+
data.tar.gz: 9e7b3b29ea91638fd8f54e5320c9fc14ceef0456057cbd40d7b1d5e9c6803cfa65a01c7c76567e147be5cefcf270ce9721c328e65944b8c873ae63591956a180
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.2.9 / 2025-05-19
|
4
|
+
|
5
|
+
* `max-width` option added.
|
6
|
+
* `width` option added as an alias for `size`.
|
7
|
+
This requires new CSS classes to be defined:
|
8
|
+
`max_eighthsize`, `max_fullsize`, `max_halfsize`, and `max_quartersize`.
|
9
|
+
* More CSS classes defined and more tests added to the Demo app to support `max-width`.
|
10
|
+
* `width='calc(something)'` added.
|
11
|
+
|
12
|
+
|
3
13
|
## 0.2.8 / 2025-05-16
|
4
14
|
|
5
15
|
* An image can now be lazily loaded by providing the `lazy` keyword.
|
data/README.md
CHANGED
@@ -249,12 +249,17 @@ $ demo/_bin/debug -r
|
|
249
249
|
- `caption="A caption"` No default value
|
250
250
|
- `classes="class1 class2 classN"` Extra <img> classes; default is `rounded shadow`
|
251
251
|
- `id="someId"` No default value
|
252
|
-
- `
|
253
|
-
- `size='eighthsize|fullsize|halfsize|initial|quartersize|XXXYY|XXX%'`
|
252
|
+
- `max-width='eighthsize|fullsize|halfsize|initial|quartersize|XXXYY|XXX%'`
|
254
253
|
Defines width of image.
|
255
254
|
- `initial` is the default behavior.
|
256
255
|
- `eighthsize`, `fullsize`, `halfsize`, and `quartersize` are relative to the enclosing tag's width.
|
257
256
|
- CSS units can also be used, for those cases `XXX` is a float and `YY` is `unit` (see below)
|
257
|
+
- `nofollow` Generates `rel='nofollow'`; only applicable when `url` is specified
|
258
|
+
- `width='eighthsize|fullsize|halfsize|initial|quartersize|XXXYY|XXX%'`
|
259
|
+
Defines width of image (alias for `size`).
|
260
|
+
- `initial` is the default behavior.
|
261
|
+
- `eighthsize`, `fullsize`, `halfsize`, and `quartersize` are relative to the enclosing tag's width.
|
262
|
+
- CSS units can also be used, for those cases `XXX` is a float and `YY` is `unit` (see below)
|
258
263
|
- `style='css goes here'` CSS style for <img>; no default
|
259
264
|
- `target='none|whatever'` Only applicable when `url` is specified; default value is `_blank`
|
260
265
|
- `title="A title"` Default value is `caption` text, if provided
|
@@ -314,8 +319,9 @@ Within the wrapper `<div />`, the embedded `<img />` is displayed with `width=10
|
|
314
319
|
If a caption is required, the generated `<figure />` only makes the space taken by the generated HTML longer;
|
315
320
|
the image’s width and height are not affected.
|
316
321
|
|
317
|
-
The wrapper will not exceed the width of the tag that encloses it if the `
|
322
|
+
The wrapper will not exceed the width of the tag that encloses it if the `width` parameter has values
|
318
323
|
`eighthsize`, `fullsize`, `halfsize`, `initial` or `quartersize`.
|
324
|
+
You can also use the `max-width` option.
|
319
325
|
|
320
326
|
The wrapper's width can be defined independently of its enclosing tag by using
|
321
327
|
[CSS units](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages)
|
data/lib/img_builder.rb
CHANGED
@@ -44,10 +44,10 @@ class ImgBuilder
|
|
44
44
|
|
45
45
|
# See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture
|
46
46
|
def generate_picture
|
47
|
-
if @props.lazy && @props.size
|
47
|
+
if @props.lazy && (@props.size || @props.max_width)
|
48
48
|
@img.logger.warn do
|
49
49
|
<<~END_MSG.squish
|
50
|
-
Warning: lazy loading was specified, but the size attribute was specified for the href tag
|
50
|
+
Warning: lazy loading was specified, but the size or max_width attribute was specified for the href tag
|
51
51
|
on line #{@img.line_number} (after front matter) of #{@img.page['path']}.
|
52
52
|
Specify dimensions via style or class attributes instead.
|
53
53
|
END_MSG
|
@@ -84,9 +84,11 @@ class ImgBuilder
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def generate_wrapper
|
87
|
-
classes = "imgWrapper #{@props.img_display} #{@props.align} #{@props.attr_size_class}
|
87
|
+
classes = ("imgWrapper #{@props.img_display} #{@props.align} #{@props.attr_size_class} " +
|
88
|
+
"#{@props.attr_max_width_class} #{@props.wrapper_class}").squish
|
89
|
+
styles = "#{@props.attr_width_style} #{@props.attr_max_width_style} #{@props.wrapper_style}".squish
|
88
90
|
<<~END_HTML.remove_blank_lines
|
89
|
-
<div class='#{classes}' style='#{
|
91
|
+
<div class='#{classes}' style='#{styles}'>
|
90
92
|
#{"<figure>\n" if @props.caption}
|
91
93
|
#{@props.url ? generate_url_wrapper : generate_picture}
|
92
94
|
#{generate_figcaption if @props.caption}
|
data/lib/img_props.rb
CHANGED
@@ -6,8 +6,8 @@ require 'uri'
|
|
6
6
|
# All methods except compute_dependant_properties can be called in any order
|
7
7
|
class ImgProperties
|
8
8
|
attr_accessor :align, :alt, :attr_wrapper_align_class, :attribute, :attribution, :caption, :classes, :die_on_img_error,
|
9
|
-
:id, :img_display, :lazy, :local_src, :nofollow, :priority, :src, :size, :style,
|
10
|
-
:url, :wrapper_class, :wrapper_style
|
9
|
+
:id, :img_display, :lazy, :local_src, :max_width, :nofollow, :priority, :src, :size, :style,
|
10
|
+
:target, :title, :url, :wrapper_class, :wrapper_style
|
11
11
|
|
12
12
|
SIZES = %w[eighthsize fullsize halfsize initial quartersize].freeze
|
13
13
|
UNITS = %w[Q ch cm em dvh dvw ex in lh lvh lvw mm pc px pt rem rlh svh svw vb vh vi vmax vmin vw %].freeze
|
@@ -29,6 +29,16 @@ class ImgProperties
|
|
29
29
|
" rel='nofollow'" if @nofollow
|
30
30
|
end
|
31
31
|
|
32
|
+
def attr_max_width_class
|
33
|
+
return nil if @max_width == false || @max_width.nil? || max_width_unit_specified?
|
34
|
+
|
35
|
+
unless SIZES.include?(@max_width)
|
36
|
+
msg = "'#{@max_width}' is not a recognized size; must be one of #{SIZES.join(', ')}, or an explicit unit."
|
37
|
+
raise Jekyll::ImgError, msg
|
38
|
+
end
|
39
|
+
"max_#{@max_width}"
|
40
|
+
end
|
41
|
+
|
32
42
|
def attr_size_class
|
33
43
|
return nil if @size == false || @size.nil? || size_unit_specified?
|
34
44
|
|
@@ -54,6 +64,10 @@ class ImgProperties
|
|
54
64
|
"title='#{@title}'" if @title && !@title.empty?
|
55
65
|
end
|
56
66
|
|
67
|
+
def attr_max_width_style
|
68
|
+
"max-width: #{@max_width};" if max_width_unit_specified?
|
69
|
+
end
|
70
|
+
|
57
71
|
def attr_width_style
|
58
72
|
"width: #{@size};" if size_unit_specified?
|
59
73
|
end
|
@@ -98,10 +112,18 @@ class ImgProperties
|
|
98
112
|
# raise Jekyll::ImgError, "#{@src} does not exist" unless File.exist?(src)
|
99
113
|
end
|
100
114
|
|
115
|
+
def max_width_unit_specified?
|
116
|
+
max_width_not_specified = @max_width == false || @max_width.to_s.strip.empty?
|
117
|
+
return false if max_width_not_specified
|
118
|
+
|
119
|
+
@max_width&.end_with?(*UNITS) || @max_width&.start_with?('calc')
|
120
|
+
end
|
121
|
+
|
101
122
|
def size_unit_specified?
|
102
|
-
|
123
|
+
size_not_specified = @size == false || @size.to_s.strip.empty?
|
124
|
+
return false if size_not_specified
|
103
125
|
|
104
|
-
@size
|
126
|
+
@size&.end_with?(*UNITS) || @size&.start_with?('calc')
|
105
127
|
end
|
106
128
|
|
107
129
|
def url?(src)
|
data/lib/jekyll_img/version.rb
CHANGED
data/lib/jekyll_img.rb
CHANGED
@@ -36,9 +36,12 @@ module Jekyll
|
|
36
36
|
props.die_on_img_error = @die_on_img_error
|
37
37
|
props.id = @helper.parameter_specified? 'id'
|
38
38
|
props.lazy = ' loading="lazy"' if @helper.parameter_specified?('lazy')
|
39
|
+
props.max_width = @helper.parameter_specified?('max-width')
|
39
40
|
props.nofollow = @helper.parameter_specified? 'nofollow'
|
40
41
|
props.priority = ' fetchpriority="high"' if @helper.parameter_specified?('priority')
|
41
|
-
props.size = @helper.parameter_specified?('size') ||
|
42
|
+
props.size = @helper.parameter_specified?('size') ||
|
43
|
+
@helper.parameter_specified?('_size') ||
|
44
|
+
@helper.parameter_specified?('width')
|
42
45
|
props.src = @helper.parameter_specified? 'src'
|
43
46
|
props.style = @helper.parameter_specified? 'style'
|
44
47
|
props.target = @helper.parameter_specified? 'target'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_img
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
104
|
+
rubygems_version: 3.7.1
|
105
105
|
specification_version: 4
|
106
106
|
summary: Provides a Jekyll tag that generates images.
|
107
107
|
test_files:
|