jekyll_img 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cda0815bbb89ab7db7f1d92af07d01f5aab7790ed1f8f7583b7745c2f0036b0e
4
- data.tar.gz: 4714cf51a294939e1ac1145b37ca713c3e00ca0a61f868924fca5fe407109458
3
+ metadata.gz: fda05bddcf8c3506b2a68947549a297afe1cceec2dd461c21cd24141d1ecfe8d
4
+ data.tar.gz: 374733466b41e6f70209ec49db53cd0e177c77f712a050cdc5ed61fa0406fa7a
5
5
  SHA512:
6
- metadata.gz: 7d01edb16a9d8339ba70a43a4d0634c898bab22c9b4b2bb9835ceebabe1fe39d9fbe2f69bfe01e50a9f2acf0312e7b62f73a2163d70bba11d7aa428c6a7fe24c
7
- data.tar.gz: cc4b935393c9cae21468c12214c8b9f2de6dcdb9ac749651ee3f51d8a8ddece1da641f09be85982e9074fafccc76fb8d954d0402c8f0b79cf4f4e27653828d25
6
+ metadata.gz: bbdaa8fb03b1cba56b855e0f02d747175ca07e248cf7343d1ba2eb6304ffaf09d86f6b30a38b44cf0116585cd4e6ecfe356c3c61853846d1e1b3523d77c873cd
7
+ data.tar.gz: 338caab74974775747ee4f21ab66c913dc2efd4a23ac0b2f9cb83d14add8f60e2a33d2d4dda3b0f72d20d782870deb4f1dbb067699d1abcd053368de021cb82f
data/.rubocop.yml CHANGED
File without changes
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.2.3 / 2024-04-27
4
+
5
+ * Depends on jekyll_plugin_support v0.8.5
6
+
7
+
8
+ ## 0.2.2 / 2024-01-08
9
+
10
+ * Added support for all image types except `avif`.
11
+
12
+
3
13
  ## 0.2.1 / 2023-11-28
4
14
 
5
15
  * Took care of the inevitable blunder when making too many changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
@@ -2,29 +2,41 @@
2
2
 
3
3
 
4
4
  `Jekyll_img` is a Jekyll plugin that embeds images in HTML documents, with alignment options,
5
- flexible resizing, default styling, overridable styling, an optional caption, and an optional URL.
5
+ flexible resizing, default styling, overridable styling, an optional caption, an optional URL,
6
+ and optional fullscreen zoom on mouseover.
7
+
8
+ Muliple image formats are supported for each image.
9
+ The user’s web browser determines the formats which it will accept.
10
+ The most desirable formats that the web browser supports are prioritized.
11
+
12
+ I explain why the `webp` image format is important in
13
+ [Converting All Images in a Website to `webp` Format](https://mslinn.com/blog/2020/08/15/converting-all-images-to-webp-format.html).
14
+ That article also provides 2 bash scripts for converting existing images to and from <code>webp</code> format.
15
+
16
+ For example, if an image is encloded in `webp`, `png` and `gif` filetypes,
17
+ and the user&rsquo;s web browser is relatively recent,
18
+ then `webp` format will give the fastest transmission and look best.
19
+ Older browsers, which might not support `webp` format,
20
+ would give best results for `png` format.
21
+ Really old web browsers would only support the `gif` file type.
6
22
 
7
- If you are not using `webp` images in your Jekyll website, this plugin is not for you.
8
23
  Please read the next section for details.
9
- If you have a use case that would benefit from expanding the supported file types,
10
- please describe your use case on the [issue tracker](https://github.com/mslinn/jekyll_img/issues/5).
11
24
 
12
25
  See [demo/index.html](demo/index.html) for examples.
13
26
 
14
27
 
15
28
  ## Image Fallback
16
29
 
17
- This plugin provides support for the
18
- [`webp`](https://developers.google.com/speed/webp) image format,
19
- with a fallback to `png` format by using the HTML
30
+ This plugin provides support for many image formats,
31
+ fallbacks to less performant formats by using the HTML
20
32
  [`picture`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture) element.
21
33
 
22
- This means that 2 versions of every image are required: a `webp` version, and a `png` version.
34
+ This means that at least one version of every image are required.
23
35
 
24
- You specify the desired image with a `webp` filetype (or no filetype),
25
- and the plugin generates a `picture` element that contains a primary
36
+ You could specify the desired image with a `webp` filetype, or you could specify no filetype.
37
+ The plugin would generate a `picture` element that contains a primary
26
38
  `source` sub-element that specifies the given image URL,
27
- and a secondary `img` sub-element with a [`png`](https://en.wikipedia.org/wiki/PNG) filetype.
39
+ and secondary `img` sub-element with all other supported filetypes.
28
40
 
29
41
  For example, these two invocations yield the same result:
30
42
 
@@ -38,16 +50,51 @@ The above generates the following
38
50
 
39
51
  ```html
40
52
  <picture>
53
+ <source srcset="blah.svg" type="image/svg" />
41
54
  <source srcset="blah.webp" type="image/webp" />
42
- <source srcset="blah.png" type="image/png" />
55
+ <source srcset="blah.apng" type="image/apng">
56
+ <source srcset="blah.png" type="image/png">
57
+ <source srcset="blah.jpg" type="image/jpeg">
58
+ <source srcset="blah.jpeg" type="image/jpeg">
59
+ <source srcset="blah.jfif" type="image/jpeg">
60
+ <source srcset="blah.pjpeg" type="image/jpeg">
61
+ <source srcset="blah.pjp" type="image/jpeg">
62
+ <source srcset="blah.gif" type="image/gif">
63
+ <source srcset="blah.tif" type="image/tiff">
64
+ <source srcset="blah.tiff" type="image/tiff">
65
+ <source srcset="blah.bmp" type="image/bmp">
66
+ <source srcset="blah.ico" type="image/x-icon">
67
+ <source srcset="blah.cur" type="image/x-icon">
43
68
  <img src="blah.png" />
44
69
  </picture>
45
70
  ```
46
71
 
47
- The above would fetch and display `blah.webp` if the web browser supported `webp` format,
72
+ If both `blah.webp` and `blah.png` were available,
73
+ the above would fetch and display `blah.webp` if the web browser supported `webp` format,
48
74
  otherwise it would fetch and display `blah.png`.
49
75
 
50
76
 
77
+ ## Supported Filetypes
78
+
79
+ The following are listed in order of priority.
80
+ See [MDN](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types) for more information.
81
+
82
+ | Filetype | MIME type |
83
+ | ------------------------------------- | --------------- |
84
+ | `svg` | `image/svg+xml` |
85
+ | `avif` | `image/avif` |
86
+ | `webp` | `image/webp` |
87
+ | `apng` | `image/apng` |
88
+ | `png` | `image/png` |
89
+ | `jpg`, `jpeg`, `jfif`, `pjpeg`, `pjp` | `image/jpeg` |
90
+ | `gif` | `image/gif` |
91
+ | `tif`, `tiff` | `image/tiff` |
92
+ | `bmp` | `image/bmp` |
93
+ | `ico`, `cur` | `image/x-icon` |
94
+
95
+ Because `avif` is problematic as of 2024-01-08 on Firefox, Chrome and Safari, it is not supported yet.
96
+
97
+
51
98
  ## Demo
52
99
 
53
100
  Run the demo website by typing:
@@ -85,6 +132,7 @@ $ demo/_bin/debug -r
85
132
  - `url='https://domain.com'` No default value
86
133
  - `wrapper_class='class1 class2 classN'` Extra CSS classes for wrapper &lt;div&gt;; no default value
87
134
  - `wrapper_style='background-color: black;'` CSS style for wrapper &lt;div&gt;; no default value
135
+ - `zoom` Fullscreen zoom on mouseover; presse escape or click outside image to dismiss
88
136
 
89
137
  [`unit`](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages)
90
138
  is one of: `Q`, `ch`, `cm`, `em`, `dvh`, `dvw`, `ex`, `in`, `lh`,
@@ -207,11 +255,13 @@ jekyll_img (0.1.0)
207
255
 
208
256
  ### Debugging
209
257
 
210
- You can cause `pry` to open when an `ImgError` is raised by setting the following in `_config.yml`:
258
+ You can cause `pry` to open when an `ImgError` is raised by setting `pry_on_img_error` in `_config.yml`.
259
+ `Pry_on_img_error` has priority `die_on_img_error`.
211
260
 
212
261
  ```yaml
213
262
  jekyll_img:
214
- pry_on_img_error: true
263
+ die_on_img_error: false # Default value is false
264
+ pry_on_img_error: true # Default value is false
215
265
  ```
216
266
 
217
267
 
data/Rakefile CHANGED
File without changes
data/jekyll_img.gemspec CHANGED
@@ -3,7 +3,6 @@ require_relative 'lib/jekyll_img/version'
3
3
  Gem::Specification.new do |spec|
4
4
  github = 'https://github.com/mslinn/jekyll_img'
5
5
 
6
- spec.bindir = 'exe'
7
6
  spec.authors = ['Mike Slinn']
8
7
  spec.email = ['mslinn@mslinn.com']
9
8
  spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
@@ -29,5 +28,5 @@ Gem::Specification.new do |spec|
29
28
  spec.version = JekyllImgVersion::VERSION
30
29
 
31
30
  spec.add_dependency 'jekyll', '>= 3.5.0'
32
- spec.add_dependency 'jekyll_plugin_support', '>= 0.8.0'
31
+ spec.add_dependency 'jekyll_plugin_support', '>= 0.8.5'
33
32
  end
data/lib/img_builder.rb CHANGED
@@ -62,8 +62,22 @@ class ImgBuilder
62
62
  img_classes = @props.classes || 'rounded shadow'
63
63
  <<~END_IMG
64
64
  <picture#{@props.attr_id} class='imgPicture'>
65
+ <source srcset="#{@props.src_any 'svg'}" type="image/svg">
66
+ <!---<source srcset="#{@props.src_any 'avif'}" type="image/avif">-->
65
67
  <source srcset="#{@props.src}" type="image/webp">
66
- <source srcset="#{@props.src_png}" type="image/png">
68
+ <source srcset="#{@props.src_any 'apng'}" type="image/apng">
69
+ <source srcset="#{@props.src_any 'png'}" type="image/png">
70
+ <source srcset="#{@props.src_any 'jpg'}" type="image/jpeg">
71
+ <source srcset="#{@props.src_any 'jpeg'}" type="image/jpeg">
72
+ <source srcset="#{@props.src_any 'jfif'}" type="image/jpeg">
73
+ <source srcset="#{@props.src_any 'pjpeg'}" type="image/jpeg">
74
+ <source srcset="#{@props.src_any 'pjp'}" type="image/jpeg">
75
+ <source srcset="#{@props.src_any 'gif'}" type="image/gif">
76
+ <source srcset="#{@props.src_any 'tif'}" type="image/tiff">
77
+ <source srcset="#{@props.src_any 'tiff'}" type="image/tiff">
78
+ <source srcset="#{@props.src_any 'bmp'}" type="image/bmp">
79
+ <source srcset="#{@props.src_any 'ico'}" type="image/x-icon">
80
+ <source srcset="#{@props.src_any 'cur'}" type="image/x-icon">
67
81
  <img #{@props.attr_alt}
68
82
  class="imgImg #{img_classes.squish}"
69
83
  src="#{@props.src_png}"
data/lib/img_props.rb CHANGED
@@ -66,6 +66,12 @@ class ImgProperties
66
66
  @title ||= @caption || @alt
67
67
  end
68
68
 
69
+ def src_any(filetype)
70
+ raise Jekyll::ImgError, "The 'src' parameter was not specified" if @src.to_s.empty?
71
+
72
+ @src.gsub('.webp', ".#{filetype}")
73
+ end
74
+
69
75
  def src_png
70
76
  raise Jekyll::ImgError, "The 'src' parameter was not specified" if @src.to_s.empty?
71
77
 
@@ -1,3 +1,3 @@
1
1
  module JekyllImgVersion
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.3'.freeze
3
3
  end
data/lib/jekyll_img.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'jekyll_plugin_support'
2
- require 'jekyll_plugin_helper'
2
+ require 'helper/jekyll_plugin_helper'
3
3
  require 'pry'
4
4
  require_relative 'img_builder'
5
5
  require_relative 'img_props'
File without changes
File without changes
File without changes
data/spec/spec_helper.rb CHANGED
File without changes
@@ -0,0 +1,10 @@
1
+ example_id | status | run_time |
2
+ ------------------------------- | ------ | --------------- |
3
+ ./spec/img_builder_spec.rb[1:1] | passed | 0.00073 seconds |
4
+ ./spec/img_props_spec.rb[1:1] | passed | 0.0001 seconds |
5
+ ./spec/img_props_spec.rb[1:2] | passed | 0.00008 seconds |
6
+ ./spec/img_props_spec.rb[1:3] | failed | 0.00051 seconds |
7
+ ./spec/img_props_spec.rb[1:4] | passed | 0.0011 seconds |
8
+ ./spec/img_props_spec.rb[1:5] | passed | 0.00019 seconds |
9
+ ./spec/img_props_spec.rb[1:6] | failed | 0.00008 seconds |
10
+ ./spec/jekyll_img_spec.rb[1:1] | failed | 0.00037 seconds |
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_img
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Slinn
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-28 00:00:00.000000000 Z
11
+ date: 2024-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.0
33
+ version: 0.8.5
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.8.0
40
+ version: 0.8.5
41
41
  description:
42
42
  email:
43
43
  - mslinn@mslinn.com
@@ -59,6 +59,7 @@ files:
59
59
  - spec/img_props_spec.rb
60
60
  - spec/jekyll_img_spec.rb
61
61
  - spec/spec_helper.rb
62
+ - spec/status_persistence.txt
62
63
  homepage: https://www.mslinn.com/jekyll_plugins/jekyll_img.html
63
64
  licenses:
64
65
  - MIT
@@ -95,4 +96,5 @@ test_files:
95
96
  - spec/img_props_spec.rb
96
97
  - spec/jekyll_img_spec.rb
97
98
  - spec/spec_helper.rb
99
+ - spec/status_persistence.txt
98
100
  ...