jekyll_picture_tag 1.10.1 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.envrc +2 -0
- data/.github/workflows/code-checks.yml +43 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +30 -0
- data/.ruby-version +1 -1
- data/docs/.envrc +2 -0
- data/docs/Gemfile +4 -2
- data/docs/Gemfile.lock +14 -12
- data/docs/_config.yml +6 -10
- data/docs/devs/contributing/code.md +46 -0
- data/docs/devs/contributing/docs.md +31 -0
- data/docs/devs/contributing/index.md +15 -0
- data/docs/devs/contributing/setup.md +33 -0
- data/docs/devs/contributing/testing.md +34 -0
- data/docs/devs/index.md +7 -0
- data/docs/{releases.md → devs/releases.md} +44 -15
- data/docs/index.md +42 -26
- data/docs/users/configuration/directories.md +34 -0
- data/docs/users/configuration/disable.md +24 -0
- data/docs/users/configuration/fast_build.md +28 -0
- data/docs/users/configuration/ignore_missing.md +23 -0
- data/docs/users/configuration/index.md +29 -0
- data/docs/users/configuration/kramdown_fix.md +20 -0
- data/docs/users/configuration/suppress_warnings.md +16 -0
- data/docs/users/configuration/urls.md +69 -0
- data/docs/users/index.md +7 -0
- data/docs/users/installation.md +52 -0
- data/docs/users/liquid_tag/argument_reference/alternate_images.md +18 -0
- data/docs/users/liquid_tag/argument_reference/attributes.md +42 -0
- data/docs/users/liquid_tag/argument_reference/base_image.md +12 -0
- data/docs/users/liquid_tag/argument_reference/crop.md +48 -0
- data/docs/users/liquid_tag/argument_reference/link.md +16 -0
- data/docs/users/liquid_tag/argument_reference/preset.md +17 -0
- data/docs/users/liquid_tag/argument_reference/readme.md +9 -0
- data/docs/users/liquid_tag/examples.md +93 -0
- data/docs/users/liquid_tag/index.md +31 -0
- data/docs/users/notes/git_lfs.md +7 -0
- data/docs/users/notes/github_pages.md +5 -0
- data/docs/users/notes/html_attributes.md +5 -0
- data/docs/users/notes/index.md +6 -0
- data/docs/users/notes/input_checking.md +6 -0
- data/docs/users/notes/kramdown_bug.md +41 -0
- data/docs/users/notes/managing_images.md +21 -0
- data/docs/{migration.md → users/notes/migration.md} +0 -0
- data/docs/users/presets/cropping.md +61 -0
- data/docs/users/presets/default.md +24 -0
- data/docs/users/presets/examples.md +79 -0
- data/docs/users/presets/fallback_image.md +28 -0
- data/docs/users/presets/html_attributes.md +26 -0
- data/docs/users/presets/image_formats.md +21 -0
- data/docs/users/presets/image_quality.md +105 -0
- data/docs/users/presets/index.md +101 -0
- data/docs/users/presets/link_source.md +16 -0
- data/docs/users/presets/markup_formats/fragments.md +48 -0
- data/docs/users/presets/markup_formats/javascript_friendly.md +57 -0
- data/docs/users/presets/markup_formats/readme.md +43 -0
- data/docs/users/presets/markup_formats/standard_html.md +25 -0
- data/docs/users/presets/media_queries.md +36 -0
- data/docs/users/presets/nomarkdown_override.md +17 -0
- data/docs/users/presets/pixel_ratio_srcsets.md +32 -0
- data/docs/users/presets/quality_width_graph.png +0 -0
- data/docs/users/presets/strip_metadata.md +13 -0
- data/docs/users/presets/width_height_attributes.md +34 -0
- data/docs/users/presets/width_srcsets.md +85 -0
- data/install_imagemagick.sh +23 -0
- data/jekyll_picture_tag.gemspec +10 -6
- data/lib/jekyll_picture_tag.rb +5 -5
- data/lib/jekyll_picture_tag/cache.rb +3 -0
- data/lib/jekyll_picture_tag/cache/base.rb +61 -0
- data/lib/jekyll_picture_tag/cache/generated.rb +20 -0
- data/lib/jekyll_picture_tag/cache/source.rb +19 -0
- data/lib/jekyll_picture_tag/defaults/global.yml +2 -0
- data/lib/jekyll_picture_tag/defaults/presets.yml +2 -0
- data/lib/jekyll_picture_tag/images.rb +3 -0
- data/lib/jekyll_picture_tag/images/generated_image.rb +130 -0
- data/lib/jekyll_picture_tag/{img_uri.rb → images/img_uri.rb} +4 -1
- data/lib/jekyll_picture_tag/images/source_image.rb +103 -0
- data/lib/jekyll_picture_tag/instructions/arg_splitter.rb +3 -2
- data/lib/jekyll_picture_tag/instructions/preset.rb +24 -4
- data/lib/jekyll_picture_tag/instructions/set.rb +5 -1
- data/lib/jekyll_picture_tag/output_formats/basic.rb +16 -14
- data/lib/jekyll_picture_tag/output_formats/img.rb +11 -0
- data/lib/jekyll_picture_tag/output_formats/picture.rb +22 -0
- data/lib/jekyll_picture_tag/router.rb +3 -2
- data/lib/jekyll_picture_tag/srcsets/basic.rb +10 -1
- data/lib/jekyll_picture_tag/utils.rb +14 -0
- data/lib/jekyll_picture_tag/version.rb +1 -1
- data/readme.md +13 -10
- metadata +139 -46
- data/.travis.yml +0 -8
- data/docs/_layouts/directory.html +0 -32
- data/docs/assets/style.css +0 -31
- data/docs/contributing.md +0 -109
- data/docs/example_presets.md +0 -116
- data/docs/global_configuration.md +0 -173
- data/docs/installation.md +0 -45
- data/docs/notes.md +0 -91
- data/docs/output.md +0 -63
- data/docs/presets.md +0 -361
- data/docs/usage.md +0 -143
- data/lib/jekyll_picture_tag/generated_image.rb +0 -161
- data/lib/jekyll_picture_tag/source_image.rb +0 -87
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
sort: 2
|
3
|
+
---
|
4
|
+
|
5
|
+
# Javascript Friendly
|
6
|
+
|
7
|
+
These are analogous to their plain HTML counterparts, but instead of `src`,
|
8
|
+
`srcset`, and `sizes`, you get `data-src`, `data-srcset`, and `data-sizes`. This
|
9
|
+
allows you to use javascript for things like [lazy
|
10
|
+
loading](https://github.com/verlok/lazyload).
|
11
|
+
|
12
|
+
- `data_picture`
|
13
|
+
|
14
|
+
```html
|
15
|
+
<picture>
|
16
|
+
<source data-srcset="..." data-sizes="...">
|
17
|
+
<source data-srcset="..." data-sizes="...">
|
18
|
+
(...)
|
19
|
+
<img data-src="...">
|
20
|
+
</picture>
|
21
|
+
```
|
22
|
+
|
23
|
+
- `data_img`
|
24
|
+
```html
|
25
|
+
<img data-srcset="..." data-src="..." data-sizes="...">
|
26
|
+
```
|
27
|
+
|
28
|
+
- `data_auto` - `data_picture` when needed, otherwise `data_img`.
|
29
|
+
|
30
|
+
## Special Options
|
31
|
+
|
32
|
+
The following preset settings only apply to these output formats.
|
33
|
+
|
34
|
+
- `noscript`
|
35
|
+
|
36
|
+
_Format:_ `noscript: true|false`
|
37
|
+
|
38
|
+
_Default:_ `false`
|
39
|
+
|
40
|
+
Include a basic `img` fallback within a `<noscript>` tag, giving your
|
41
|
+
non-javascript-running users something to look at.
|
42
|
+
|
43
|
+
```html
|
44
|
+
<img data-srcset="..." data-src="..." data-sizes="...">
|
45
|
+
<noscript>
|
46
|
+
<img src="..." alt="...">
|
47
|
+
</noscript>
|
48
|
+
```
|
49
|
+
|
50
|
+
- `data_sizes`
|
51
|
+
|
52
|
+
_Format:_ `data_sizes: true|false`
|
53
|
+
|
54
|
+
_Default:_ `true`
|
55
|
+
|
56
|
+
This option sets whether you would like JPT's auto-generated sizes to be returned as a
|
57
|
+
`data-sizes` attribute or a normal `sizes` attribute.
|
@@ -0,0 +1,43 @@
|
|
1
|
+
---
|
2
|
+
sort: 1
|
3
|
+
---
|
4
|
+
|
5
|
+
# Markup Formats
|
6
|
+
|
7
|
+
Define what format the generated text will take. Select one by setting
|
8
|
+
`markup:` in the relevant [preset]({{ site.baseurl }}/users/presets).
|
9
|
+
|
10
|
+
_Format:_ `markup: (setting)`
|
11
|
+
|
12
|
+
_Default_: `auto`
|
13
|
+
|
14
|
+
|
15
|
+
Example:
|
16
|
+
|
17
|
+
```yml
|
18
|
+
# /_data/picture.yml
|
19
|
+
|
20
|
+
markup_presets:
|
21
|
+
my_preset:
|
22
|
+
markup: data_auto
|
23
|
+
```
|
24
|
+
|
25
|
+
## Valid options:
|
26
|
+
|
27
|
+
### Standard HTML:
|
28
|
+
- `auto` - default
|
29
|
+
- `picture`
|
30
|
+
- `img`
|
31
|
+
|
32
|
+
### Javascript Friendly:
|
33
|
+
- `data_auto`
|
34
|
+
- `data_picture`
|
35
|
+
- `data_img`
|
36
|
+
|
37
|
+
### Fragments:
|
38
|
+
- `direct_url`
|
39
|
+
- `naked_srcset`
|
40
|
+
|
41
|
+
## Reference:
|
42
|
+
|
43
|
+
{% include list.liquid %}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
sort: 1
|
3
|
+
---
|
4
|
+
|
5
|
+
# Standard HTML
|
6
|
+
|
7
|
+
- **`picture`** - `<picture>` element surrounding a `<source>` tag for each required srcset, and a
|
8
|
+
fallback `<img>`:
|
9
|
+
|
10
|
+
```html
|
11
|
+
<picture>
|
12
|
+
<source srcset="..." sizes="..." media="..." type="...">
|
13
|
+
<source srcset="..." sizes="..." media="..." type="...">
|
14
|
+
(...)
|
15
|
+
<img src="...">
|
16
|
+
</picture
|
17
|
+
```
|
18
|
+
|
19
|
+
- **`img`** - a single `<img>` tag with a `srcset` entry:
|
20
|
+
|
21
|
+
```html
|
22
|
+
<img src="..." srcset="..." sizes="..." alt="..." width="..." height="...">
|
23
|
+
```
|
24
|
+
|
25
|
+
- **`auto`** - Supply an img tag when you have only one srcset, otherwise supply a picture tag.
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
sort: 1
|
3
|
+
---
|
4
|
+
|
5
|
+
# Media Queries
|
6
|
+
|
7
|
+
Jekyll Picture Tag handles media queries by letting you define them by name in
|
8
|
+
`_data/picture.yml`, and then referencing that name whenever you need it.
|
9
|
+
|
10
|
+
_Format:_
|
11
|
+
|
12
|
+
```yaml
|
13
|
+
# _data/picture.yml
|
14
|
+
|
15
|
+
media_queries:
|
16
|
+
(name): (css media query)
|
17
|
+
(name): (css media query)
|
18
|
+
(...)
|
19
|
+
|
20
|
+
```
|
21
|
+
|
22
|
+
_Example:_
|
23
|
+
|
24
|
+
```yaml
|
25
|
+
# _data/picture.yml
|
26
|
+
|
27
|
+
media_queries:
|
28
|
+
mobile: "max-width: 600px"
|
29
|
+
tablet: "max-width: 800px"
|
30
|
+
ultrawide: "min-width: 1400px"
|
31
|
+
```
|
32
|
+
|
33
|
+
They are used in a few different places: specifying alternate source images in
|
34
|
+
your liquid tag, building the 'sizes' attribute within your presets, and in a
|
35
|
+
few configuration settings. Quotes are recommended, because yml gets confused by
|
36
|
+
colons.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
sort: 11
|
3
|
+
---
|
4
|
+
|
5
|
+
# Nomarkdown Override
|
6
|
+
|
7
|
+
_Format:_ `nomarkdown: (true|false)`
|
8
|
+
|
9
|
+
_Example:_ `nomarkdown: false`
|
10
|
+
|
11
|
+
_Default:_ `nil`
|
12
|
+
|
13
|
+
Hard setting for `{::nomarkdown}` tags, overrides both autodetection and the
|
14
|
+
global setting in `_config.yml`.
|
15
|
+
|
16
|
+
See this [note]({{ site.baseurl }}/users/notes/kramdown_bug) for a detailed
|
17
|
+
explanation.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
sort: 4
|
3
|
+
---
|
4
|
+
|
5
|
+
# Pixel Ratio Srcsets
|
6
|
+
|
7
|
+
A Pixel Ratio srcset looks like this:
|
8
|
+
|
9
|
+
```html
|
10
|
+
srcset="myimage-200.jpg 1.0x, myimage-300.jpg 1.5x, myimage-400.jpg 2.0x"
|
11
|
+
```
|
12
|
+
|
13
|
+
To use one, set `pixel_ratios` and `base_width`. They are most appropriate for
|
14
|
+
thumbnails and icons, where the image will be the same size on all screens, and
|
15
|
+
all you need to account for is pixel ratio.
|
16
|
+
|
17
|
+
## Base Width
|
18
|
+
|
19
|
+
_Format:_ `base_width: integer`
|
20
|
+
|
21
|
+
_Example:_ `base_width: 100`
|
22
|
+
|
23
|
+
Sets how wide the 1x image should be. Required when using a Pixel Ratio srcset.
|
24
|
+
|
25
|
+
## Pixel Ratios
|
26
|
+
|
27
|
+
_Format:_ `pixel_ratios: [number, number, number (...)]`
|
28
|
+
|
29
|
+
_Example:_ `pixel_ratios: [1, 1.5, 2]`
|
30
|
+
|
31
|
+
Array of images to construct, given in multiples of the base width.
|
32
|
+
|
Binary file
|
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
sort: 7
|
3
|
+
---
|
4
|
+
|
5
|
+
# Width & Height (Anti-Loading-Jank)
|
6
|
+
|
7
|
+
_Format:_
|
8
|
+
|
9
|
+
```yml
|
10
|
+
dimension_attributes: true | false
|
11
|
+
```
|
12
|
+
|
13
|
+
_Example:_
|
14
|
+
|
15
|
+
```yml
|
16
|
+
dimension_attributes: true
|
17
|
+
```
|
18
|
+
|
19
|
+
_Default:_ `false`
|
20
|
+
|
21
|
+
Prevent page reflow (aka jank) while images are loading, by adding `width` and
|
22
|
+
`height` attributes to the `<img>` tag in the correct aspect ratio.
|
23
|
+
|
24
|
+
For an explanation of why and how you want to do this,
|
25
|
+
[here](https://youtu.be/4-d_SoCHeWE) is a great explanation.
|
26
|
+
|
27
|
+
Caveats:
|
28
|
+
* You need either `width: auto;` or `height: auto;` set in CSS on the `<img>`
|
29
|
+
tags, or they will be stretched.
|
30
|
+
* This works on `<img>` tags and `<picture>` tags when offering images in
|
31
|
+
multiple widths and formats, but it does not work if you are using art
|
32
|
+
direction (in other words, if you have multiple source images). This is
|
33
|
+
because these attributes can only be applied to the `<img>` tag, of which
|
34
|
+
there is exactly one.
|
@@ -0,0 +1,85 @@
|
|
1
|
+
---
|
2
|
+
sort: 3
|
3
|
+
---
|
4
|
+
|
5
|
+
# Width Based Srcsets
|
6
|
+
|
7
|
+
A width based srcset looks like this:
|
8
|
+
|
9
|
+
```html
|
10
|
+
srcset="myimage-800.jpg 800w, myimage-1200.jpg 1200w, myimage-2000.jpg 2000w"
|
11
|
+
```
|
12
|
+
|
13
|
+
It's the default; to use it specify a `widths` setting (or don't, for the
|
14
|
+
default set), and optionally the `sizes` and `size` settings.
|
15
|
+
|
16
|
+
## Widths
|
17
|
+
|
18
|
+
_Format:_ `widths: [integer, integer, (...)]`
|
19
|
+
|
20
|
+
_Example:_ `widths: [600, 800, 1200]`
|
21
|
+
|
22
|
+
_Default_: `[400, 600, 800, 1000]`
|
23
|
+
|
24
|
+
Array of image widths to generate, in pixels.
|
25
|
+
|
26
|
+
## Media Widths
|
27
|
+
|
28
|
+
_Format:_
|
29
|
+
|
30
|
+
```yml
|
31
|
+
media_widths:
|
32
|
+
(media_query name): [integer, integer, (...)]
|
33
|
+
```
|
34
|
+
|
35
|
+
_Example:_
|
36
|
+
|
37
|
+
```yml
|
38
|
+
media_widths:
|
39
|
+
mobile: [400, 600, 800]
|
40
|
+
```
|
41
|
+
|
42
|
+
_Default:_ `widths` setting
|
43
|
+
|
44
|
+
If you are using art direction, there is no sense in generating desktop-size
|
45
|
+
files for your mobile image. You can specify sets of widths to associate with
|
46
|
+
given media queries. If not specified, will use `widths` setting.
|
47
|
+
|
48
|
+
## Sizes
|
49
|
+
|
50
|
+
_Format:_
|
51
|
+
|
52
|
+
```yml
|
53
|
+
sizes:
|
54
|
+
(media preset): (CSS dimension)
|
55
|
+
(...)
|
56
|
+
```
|
57
|
+
|
58
|
+
_Example:_
|
59
|
+
|
60
|
+
```yml
|
61
|
+
sizes:
|
62
|
+
mobile: 80vw
|
63
|
+
tablet: 60vw
|
64
|
+
desktop: 900px
|
65
|
+
```
|
66
|
+
|
67
|
+
Conditional sizes, used to construct the `sizes=` HTML attribute telling the
|
68
|
+
browser how wide your image will be (on the screen) when a given media query
|
69
|
+
is true. CSS dimensions can be given in `px`, `em`, or `vw`. To be used along
|
70
|
+
with a width-based srcset.
|
71
|
+
|
72
|
+
Provide these in order of most restrictive to least restrictive. The browser
|
73
|
+
will choose the first one with an applicable media query.
|
74
|
+
|
75
|
+
You don't have to provide a sizes attribute at all. If you don't, the browser
|
76
|
+
will assume the image is 100% the width of the viewport.
|
77
|
+
|
78
|
+
## Size
|
79
|
+
|
80
|
+
_Format:_ `size: (CSS Dimension)`
|
81
|
+
|
82
|
+
_Example:_ `size: 80vw`
|
83
|
+
|
84
|
+
Unconditional `sizes` setting, to be supplied either alone or after all
|
85
|
+
conditional sizes.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Configure and install imagemagick; detects if cached compiled version exists.
|
2
|
+
|
3
|
+
check_cached() {
|
4
|
+
[ "$(find . -name '*.o')" ]
|
5
|
+
}
|
6
|
+
|
7
|
+
build_im() {
|
8
|
+
git clone 'https://github.com/ImageMagick/ImageMagick' ./ \
|
9
|
+
--branch "$imagemagick_version"
|
10
|
+
|
11
|
+
rm -rf '.git'
|
12
|
+
|
13
|
+
./configure
|
14
|
+
make
|
15
|
+
}
|
16
|
+
|
17
|
+
[ -d 'imagemagick' ] || mkdir imagemagick
|
18
|
+
cd imagemagick
|
19
|
+
|
20
|
+
check_cached || build_im
|
21
|
+
|
22
|
+
sudo make install
|
23
|
+
sudo ldconfig /usr/local/lib
|
data/jekyll_picture_tag.gemspec
CHANGED
@@ -29,19 +29,23 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
31
31
|
spec.add_development_dependency 'minitest', '~> 5.11'
|
32
|
+
spec.add_development_dependency 'minitest-rg'
|
32
33
|
spec.add_development_dependency 'mocha', '~> 1.9'
|
33
34
|
spec.add_development_dependency 'nokogiri', '~> 1.10'
|
34
35
|
spec.add_development_dependency 'pry'
|
35
36
|
spec.add_development_dependency 'rake', '~> 12.3'
|
36
|
-
spec.add_development_dependency 'rubocop'
|
37
|
-
spec.add_development_dependency '
|
37
|
+
spec.add_development_dependency 'rubocop', '~> 1.7.0'
|
38
|
+
spec.add_development_dependency 'rubocop-minitest', '~> 0.10.0'
|
39
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.9.0'
|
40
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.5.0'
|
41
|
+
|
42
|
+
spec.add_development_dependency 'simplecov', '~> 0.20.0'
|
38
43
|
spec.add_development_dependency 'solargraph'
|
39
44
|
|
40
45
|
spec.add_dependency 'addressable', '~> 2.6'
|
41
|
-
spec.add_dependency '
|
42
|
-
spec.add_dependency '
|
43
|
-
spec.add_dependency '
|
44
|
-
spec.add_dependency 'objective_elements', '~> 1.1.2'
|
46
|
+
spec.add_dependency 'mime-types', '~> 3.0'
|
47
|
+
spec.add_dependency 'mini_magick', '~> 4.0'
|
48
|
+
spec.add_dependency 'objective_elements', '~> 1.1'
|
45
49
|
|
46
50
|
spec.add_runtime_dependency 'jekyll', '< 5'
|
47
51
|
end
|
data/lib/jekyll_picture_tag.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
require 'jekyll'
|
2
2
|
require 'objective_elements'
|
3
3
|
|
4
|
-
require_relative 'jekyll_picture_tag/
|
4
|
+
require_relative 'jekyll_picture_tag/cache'
|
5
|
+
require_relative 'jekyll_picture_tag/images'
|
5
6
|
require_relative 'jekyll_picture_tag/instructions'
|
6
7
|
require_relative 'jekyll_picture_tag/output_formats'
|
7
|
-
require_relative 'jekyll_picture_tag/
|
8
|
+
require_relative 'jekyll_picture_tag/router'
|
8
9
|
require_relative 'jekyll_picture_tag/srcsets'
|
9
10
|
require_relative 'jekyll_picture_tag/utils'
|
10
|
-
require_relative 'jekyll_picture_tag/img_uri'
|
11
|
-
require_relative 'jekyll_picture_tag/router'
|
12
11
|
|
13
12
|
# Title: Jekyll Picture Tag
|
14
13
|
# Authors: Rob Wierzbowski : @robwierzbowski
|
@@ -51,6 +50,7 @@ module PictureTag
|
|
51
50
|
# care about the params (arguments passed to the liquid tag). Jekyll makes
|
52
51
|
# no attempt to parse them; they're given as a string.
|
53
52
|
def initialize(tag_name, raw_params, tokens)
|
53
|
+
Utils.warning 'You have called JPT without any arguments.' if raw_params.empty?
|
54
54
|
@raw_params = raw_params
|
55
55
|
super
|
56
56
|
end
|
@@ -61,7 +61,7 @@ module PictureTag
|
|
61
61
|
def render(context)
|
62
62
|
setup(context)
|
63
63
|
|
64
|
-
if PictureTag.disabled?
|
64
|
+
if PictureTag.disabled? || @raw_params.empty?
|
65
65
|
''
|
66
66
|
else
|
67
67
|
PictureTag.output_class.new.to_s
|