jekyll_picture_tag 1.7.1 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -7
- data/Dockerfile +9 -0
- data/docs/Gemfile.lock +183 -88
- data/docs/contributing.md +50 -16
- data/docs/example_presets.md +1 -1
- data/docs/global_configuration.md +55 -2
- data/docs/index.md +26 -20
- data/docs/installation.md +22 -7
- data/docs/notes.md +11 -1
- data/docs/output.md +32 -21
- data/docs/presets.md +109 -54
- data/docs/releases.md +17 -1
- data/docs/usage.md +68 -38
- data/jekyll_picture_tag.gemspec +2 -1
- data/lib/jekyll_picture_tag.rb +27 -10
- 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/generated_image.rb +105 -19
- data/lib/jekyll_picture_tag/instructions.rb +1 -0
- data/lib/jekyll_picture_tag/instructions/arg_splitter.rb +68 -0
- data/lib/jekyll_picture_tag/instructions/configuration.rb +47 -11
- data/lib/jekyll_picture_tag/instructions/preset.rb +34 -14
- data/lib/jekyll_picture_tag/instructions/set.rb +18 -8
- data/lib/jekyll_picture_tag/instructions/tag_parser.rb +59 -69
- data/lib/jekyll_picture_tag/output_formats/basic.rb +36 -7
- data/lib/jekyll_picture_tag/output_formats/data_attributes.rb +4 -1
- data/lib/jekyll_picture_tag/router.rb +16 -0
- data/lib/jekyll_picture_tag/source_image.rb +6 -1
- data/lib/jekyll_picture_tag/srcsets/basic.rb +45 -19
- data/lib/jekyll_picture_tag/srcsets/pixel_ratio.rb +1 -3
- data/lib/jekyll_picture_tag/srcsets/width.rb +1 -1
- data/lib/jekyll_picture_tag/utils.rb +18 -0
- data/lib/jekyll_picture_tag/version.rb +1 -1
- data/readme.md +39 -16
- metadata +24 -8
data/docs/example_presets.md
CHANGED
@@ -75,7 +75,7 @@ markup_presets:
|
|
75
75
|
# your source images will need to be part of the deployed site for this to
|
76
76
|
# work. If you have issues such as mangled HTML or extra {::nomarkdown}
|
77
77
|
# tags floating around, see docs/notes.md
|
78
|
-
|
78
|
+
link_source: true
|
79
79
|
|
80
80
|
# This is an example of how you would create a 'multiplier' based srcset;
|
81
81
|
# useful when an image will always be the same size on all screens (icons,
|
@@ -65,7 +65,12 @@ picture:
|
|
65
65
|
|
66
66
|
*Default:* `false`
|
67
67
|
|
68
|
-
Normally, JPT will raise an error if a source image is missing, causing the entire site build to
|
68
|
+
Normally, JPT will raise an error if a source image is missing, causing the entire site build to
|
69
|
+
fail. This setting allows you to bypass this behavior and continue the build, either for certain
|
70
|
+
build environments or all the time. I highly encourage you to set this to `development`, and set
|
71
|
+
the jekyll build environment to `production` when you build for production so you don't shoot
|
72
|
+
yourself in the foot (publish a site with broken images). You can read more about Jekyll
|
73
|
+
environments [here](https://jekyllrb.com/docs/configuration/environments/).
|
69
74
|
|
70
75
|
* **Use Relative Urls**
|
71
76
|
|
@@ -111,10 +116,58 @@ picture:
|
|
111
116
|
|
112
117
|
*Example:* `nomarkdown: false`
|
113
118
|
|
114
|
-
*Default
|
119
|
+
*Default:* `true`
|
115
120
|
|
116
121
|
Whether or not to surround j-p-t's output with a `{::nomarkdown}..{:/nomarkdown}` block when called
|
117
122
|
from within a markdown file.
|
118
123
|
|
119
124
|
This setting is overridden by the same setting in a preset. See [the notes]({{ site.baseurl
|
120
125
|
}}/notes) for more detailed information.
|
126
|
+
|
127
|
+
* **Fast Build**
|
128
|
+
|
129
|
+
*Format:* `fast_build: (true|false|environment|array of environments)`
|
130
|
+
|
131
|
+
*Examples:*
|
132
|
+
|
133
|
+
- `fast_build: true`
|
134
|
+
|
135
|
+
- `fast_build: development`
|
136
|
+
|
137
|
+
- `fast_build: [development, staging]`
|
138
|
+
|
139
|
+
*Default:* `false`
|
140
|
+
|
141
|
+
Makes a tradeoff: Speeds repeated build times for sites with many images, by assuming that the
|
142
|
+
filename alone is enough to uniquely identify a source image. This doesn't speed up image
|
143
|
+
generation, just detection of whether or not it's necessary.
|
144
|
+
|
145
|
+
Ordinarily, JPT generates an MD5 hash for every source image, every site build. This ensures that
|
146
|
+
if you replace one image with another, but keep the filename the same, JPT will correctly generate
|
147
|
+
images for the new file. If you have many large images and/or limited hardware, this can take some
|
148
|
+
time and make the development process painful. Enable this setting to skip MD5 hash checking on
|
149
|
+
existing generated images (most of the time), and just assume that if the filename, format, and
|
150
|
+
width match then it's the right one. If there are multiple possible matches (resulting from
|
151
|
+
leftover generated images from previous filename replacements), it'll compute a hash instead of
|
152
|
+
guessing randomly.
|
153
|
+
|
154
|
+
* **Disable Jekyll Picture Tag**
|
155
|
+
|
156
|
+
*Format:* `disabled: (true|false|environment|array of environments)`
|
157
|
+
|
158
|
+
*Examples:*
|
159
|
+
|
160
|
+
- `disabled: true`
|
161
|
+
|
162
|
+
- `disabled: development`
|
163
|
+
|
164
|
+
- `disabled: [development, staging]`
|
165
|
+
|
166
|
+
*Default:* `false`
|
167
|
+
|
168
|
+
Disable image and markup generation entirely. Useful for debugging, or to speed up site builds
|
169
|
+
when you're working on something else.
|
170
|
+
|
171
|
+
Hint: If you're going to toggle this on and off frequently, you might just use an environment
|
172
|
+
variable. Set this to something like `nopics`, and then start the Jekyll server with something
|
173
|
+
like `JEKYLL_ENV=nopics bundle exec jekyll serve` when you don't want image generation.
|
data/docs/index.md
CHANGED
@@ -39,10 +39,10 @@ markup_presets:
|
|
39
39
|
|
40
40
|
### Here's a more complete demonstration:
|
41
41
|
|
42
|
-
[Presets]({{ site.baseurl }}/presets) are named collections of settings
|
43
|
-
|
44
|
-
|
45
|
-
examples).
|
42
|
+
[Presets]({{ site.baseurl }}/presets) are named collections of settings, and come in 2 kinds: Media
|
43
|
+
Presets are named CSS media queries, and Markup Presets determine the output text and images. You
|
44
|
+
choose one with the second [tag parameter]({{ site.baseurl }}/usage), or omit for the `default` (as
|
45
|
+
in these examples). They are located in `_data/picture.yml`. Here's an example:
|
46
46
|
|
47
47
|
```yml
|
48
48
|
media_presets:
|
@@ -57,13 +57,15 @@ markup_presets:
|
|
57
57
|
size: 500px
|
58
58
|
```
|
59
59
|
|
60
|
-
|
60
|
+
Imagemagick can easily crop images to an aspect ratio, though you should **read the whole
|
61
|
+
installation guide before using this feature**. With the above preset, if you write this:
|
62
|
+
|
61
63
|
|
62
64
|
{% raw %}
|
63
|
-
`{% picture test.jpg mobile: test2.jpg --alt Alternate Text %}`
|
65
|
+
`{% picture test.jpg 3:2 mobile: test2.jpg 1:1 --alt Alternate Text %}`
|
64
66
|
{% endraw %}
|
65
67
|
|
66
|
-
|
68
|
+
You'll get something like this:
|
67
69
|
|
68
70
|
```html
|
69
71
|
<!-- Formatted for readability -->
|
@@ -73,36 +75,40 @@ Get this:
|
|
73
75
|
sizes="(max-width: 600px) 80vw, 600px"
|
74
76
|
media="(max-width: 600px)"
|
75
77
|
srcset="
|
76
|
-
/generated/test2-600-
|
77
|
-
/generated/test2-900-
|
78
|
-
/generated/test2-1200-
|
78
|
+
/generated/test2-600-21bb6fGUW.webp 600w,
|
79
|
+
/generated/test2-900-21bb6fGUW.webp 900w,
|
80
|
+
/generated/test2-1200-21bb6fGUW.webp 1200w
|
79
81
|
"
|
80
82
|
type="image/webp">
|
81
83
|
<source
|
82
84
|
sizes="(max-width: 600px) 80vw, 600px"
|
83
85
|
srcset="
|
84
|
-
/generated/test-600-
|
85
|
-
/generated/test-900-
|
86
|
-
/generated/test-1200-
|
86
|
+
/generated/test-600-195f7d192.webp 600w,
|
87
|
+
/generated/test-900-195f7d192.webp 900w,
|
88
|
+
/generated/test-1200-195f7d192.webp 1200w
|
87
89
|
"
|
88
90
|
type="image/webp">
|
89
91
|
<source
|
90
92
|
sizes="(max-width: 600px) 80vw, 600px"
|
91
93
|
media="(max-width: 600px)"
|
92
94
|
srcset="
|
93
|
-
/generated/test2-600-
|
94
|
-
/generated/test2-900-
|
95
|
-
/generated/test2-1200-
|
95
|
+
/generated/test2-600-21bb6fGUW.jpg 600w,
|
96
|
+
/generated/test2-900-21bb6fGUW.jpg 900w,
|
97
|
+
/generated/test2-1200-21bb6fGUW.jpg 1200w
|
96
98
|
"
|
97
99
|
type="image/jpeg">
|
98
100
|
<source
|
99
101
|
sizes="(max-width: 600px) 80vw, 600px"
|
100
102
|
srcset="
|
101
|
-
/generated/test-600-
|
102
|
-
/generated/test-900-
|
103
|
-
/generated/test-1200-
|
103
|
+
/generated/test-600-195f7d192.jpg 600w,
|
104
|
+
/generated/test-900-195f7d192.jpg 900w,
|
105
|
+
/generated/test-1200-195f7d192.jpg 1200w
|
104
106
|
"
|
105
107
|
type="image/jpeg">
|
106
|
-
<img src="/generated/test-800-
|
108
|
+
<img src="/generated/test-800-195f7dGUW.jpg" alt="Alternate Text">
|
107
109
|
</picture>
|
108
110
|
```
|
111
|
+
|
112
|
+
In other words, you have the art direction, format switching, and resolution switching problems
|
113
|
+
*solved*, with a one-liner and a nicely readable config file that is 1/3 as long as the output
|
114
|
+
markup. Lighthouse is happy, and you don't even need to crop things yourself.
|
data/docs/installation.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
---
|
2
2
|
---
|
3
|
+
|
3
4
|
# Installation
|
4
5
|
|
5
|
-
|
6
|
+
- Add `jekyll_picture_tag` to your Gemfile in the `:jekyll_plugins` group:
|
6
7
|
|
7
8
|
```ruby
|
8
9
|
group :jekyll_plugins do
|
@@ -10,21 +11,35 @@
|
|
10
11
|
end
|
11
12
|
```
|
12
13
|
|
13
|
-
|
14
|
+
- Run `$ bundle install`
|
14
15
|
|
15
|
-
|
16
|
+
- See if you have ImageMagick with `$ convert --version`. You should see something like this:
|
16
17
|
|
17
18
|
```
|
18
|
-
~ $ convert --version
|
19
|
+
~ $ convert --version
|
19
20
|
Version: ImageMagick 7.0.8-14 Q16 x86_64 2018-10-31 https://imagemagick.org
|
20
21
|
Copyright: © 1999-2018 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php
|
21
22
|
Features: Cipher DPC HDRI OpenMP Delegates (built-in): bzlib fontconfig freetype jng jp2 jpeg lcms
|
22
23
|
lzma pangocairo png tiff webp xml zlib
|
23
24
|
```
|
25
|
+
|
24
26
|
If you get a 'command not found' error, you'll need to install it. Most package managers know about
|
25
27
|
ImageMagick, otherwise it can be found [here](https://imagemagick.org/script/download.php).
|
26
28
|
|
27
|
-
|
28
|
-
you want to handle will require an appropriate delegate; You may have to install additional packages
|
29
|
-
to accomplish this.
|
29
|
+
- **Note webp under delegates.** This is required if you want to generate webp files. Any image format
|
30
|
+
you want to handle will require an appropriate delegate; You may have to install additional packages
|
31
|
+
to accomplish this.
|
32
|
+
|
33
|
+
## Cropping and Imagemagick
|
34
|
+
|
35
|
+
Cropping to an aspect ratio depends on ImageMagick 7+. Ubuntu, somewhat annoyingly, only offers
|
36
|
+
version 6 in its official repositories. This matters even if you don't run Ubuntu, because many
|
37
|
+
build & deployment services you might use (including Netlify and Travis CI) do.
|
38
|
+
|
39
|
+
If you'd like to use both the cropping feature and such a service, or it's inconvenient to install
|
40
|
+
version 7 in your development environment, you will likely want to build your site in a docker
|
41
|
+
container. The Alpine Linux repos include version 7, so you'll want an Alpine Linux based image
|
42
|
+
rather than an Ubuntu based one. Conveniently this includes the [offical Jekyll
|
43
|
+
image](https://hub.docker.com/r/jekyll/jekyll).
|
30
44
|
|
45
|
+
Once I work out how to actually do that, I'll add some guidance here.
|
data/docs/notes.md
CHANGED
@@ -12,7 +12,17 @@
|
|
12
12
|
|
13
13
|
Jekyll Picture Tag has comprehensive attribute support for all generated HTML. You can add
|
14
14
|
attributes both through the [liquid tag]({{ site.baseurl }}/usage), and the [preset]({{
|
15
|
-
site.baseurl }}/presets) (scroll down a
|
15
|
+
site.baseurl }}/presets) (scroll down a bit).
|
16
|
+
|
17
|
+
* ### Input checking
|
18
|
+
|
19
|
+
Jekyll Picture Tag is very trusting. It doesn't do much checking of your inputs, and it does not
|
20
|
+
fail gracefully if you for example pass it a string when it expects an array. It's on the to-do
|
21
|
+
list, but for now if you get cryptic errors then double-check your settings and tag arguments.
|
22
|
+
|
23
|
+
* ### Git LFS
|
24
|
+
|
25
|
+
I'm Putting this here because it bit me: If you want to use git LFS, make sure that your hosting
|
16
26
|
provider makes those images available during the build process. Netlify, for example, does not.
|
17
27
|
You won't find this out until you have gone through the entire migration process and try to deploy
|
18
28
|
for the first time.
|
data/docs/output.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
This is a listing of the various text arrangements that JPT can give you. Select one by setting
|
7
7
|
`markup:` in the relevant [markup preset]({{ site.baseurl }}/presets).
|
8
8
|
|
9
|
-
Example:
|
9
|
+
Example:
|
10
10
|
|
11
11
|
```yml
|
12
12
|
# /_data/picture.yml
|
@@ -18,35 +18,46 @@ markup_presets:
|
|
18
18
|
|
19
19
|
## Standard HTML:
|
20
20
|
|
21
|
-
|
21
|
+
- **`picture`:** `<picture>` element surrounding a `<source>` tag for each required srcset, and a
|
22
22
|
fallback `<img>`.
|
23
23
|
|
24
|
-
|
24
|
+
- **`img`:** output a single `<img>` tag with a `srcset` entry.
|
25
25
|
|
26
|
-
|
26
|
+
- **`auto`:** Supply an img tag when you have only one srcset, otherwise supply a picture tag.
|
27
27
|
|
28
28
|
## Javascript Friendly:
|
29
29
|
|
30
|
-
|
31
|
-
`src`, `srcset`, and `sizes`, you get `data-src`, `data-srcset`, and `data-sizes`. This allows you
|
32
|
-
to use javascript for things like [lazy loading](https://github.com/verlok/lazyload).
|
33
|
-
basic `img` fallback within a `<noscript>` tag by setting `noscript: true` in the preset. This
|
34
|
-
allows you to keep working images for your non-javascript-enabled users.
|
30
|
+
- **`data_picture`, `data_img`, `data_auto`:** Analogous to their counterparts above, but instead of
|
31
|
+
`src`, `srcset`, and `sizes`, you get `data-src`, `data-srcset`, and `data-sizes`. This allows you
|
32
|
+
to use javascript for things like [lazy loading](https://github.com/verlok/lazyload).
|
35
33
|
|
36
|
-
|
34
|
+
#### Special Options
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
36
|
+
The following preset configuration settings only apply to the `data_` output formats.
|
37
|
+
|
38
|
+
- **noscript**
|
39
|
+
|
40
|
+
_Format:_ `noscript: true|false`
|
41
|
+
|
42
|
+
_Default:_ `false`
|
43
|
+
|
44
|
+
Include a basic `img` fallback within a `<noscript>` tag, giving your javascript-disabled users
|
45
|
+
something to look at.
|
46
|
+
|
47
|
+
- **data_sizes**
|
48
|
+
|
49
|
+
_Format:_ `data_sizes: true|false`
|
50
|
+
|
51
|
+
_Default:_ `true`
|
52
|
+
|
53
|
+
This option sets whether you would like JPT's auto-generated sizes to be returned as a
|
54
|
+
`data-sizes` attribute or a normal `sizes` attribute. (Useful for interfacing nicely with all the
|
55
|
+
various JS image libraries out there.)
|
45
56
|
|
46
57
|
## Fragments:
|
47
58
|
|
48
|
-
|
49
|
-
and format).
|
59
|
+
- **`direct_url`**: Generates an image and returns only its url. Uses `fallback_` properties (width
|
60
|
+
and format).
|
50
61
|
|
51
|
-
|
52
|
-
(image) `format` setting must still be an array, even if you only give it one value.
|
62
|
+
- **`naked_srcset`**: Builds a srcset and nothing else (not even the surrounding quotes). Note that the
|
63
|
+
(image) `format` setting must still be an array, even if you only give it one value.
|
data/docs/presets.md
CHANGED
@@ -9,6 +9,9 @@ this file, and probably the `_data/` directory as well.
|
|
9
9
|
|
10
10
|
Here's an [example data file]({{ site.baseurl }}/example_presets).
|
11
11
|
|
12
|
+
Any settings which are specific to particular output formats are documented on the [output
|
13
|
+
formats]({{site.baseurl}}/output) page.
|
14
|
+
|
12
15
|
## Required Knowledge
|
13
16
|
|
14
17
|
If you don't know the difference between resolution switching and art direction, stop now and read
|
@@ -19,7 +22,7 @@ browser widths until you understand it.
|
|
19
22
|
|
20
23
|
## Media Presets
|
21
24
|
|
22
|
-
|
25
|
+
_Format:_
|
23
26
|
|
24
27
|
```yml
|
25
28
|
media_presets:
|
@@ -29,11 +32,11 @@ media_presets:
|
|
29
32
|
|
30
33
|
```
|
31
34
|
|
32
|
-
|
35
|
+
_Example:_
|
33
36
|
|
34
37
|
```yml
|
35
38
|
media_presets:
|
36
|
-
desktop:
|
39
|
+
desktop: "min-width: 1200px"
|
37
40
|
```
|
38
41
|
|
39
42
|
These are named media queries for use in a few different places: specifying alternate source images
|
@@ -42,7 +45,7 @@ settings. Quotes are recommended around the media queries, because yml gets conf
|
|
42
45
|
|
43
46
|
## Markup Presets
|
44
47
|
|
45
|
-
|
48
|
+
_Format:_
|
46
49
|
|
47
50
|
```yml
|
48
51
|
markup_presets:
|
@@ -53,7 +56,7 @@ markup_presets:
|
|
53
56
|
(...)
|
54
57
|
```
|
55
58
|
|
56
|
-
|
59
|
+
_Example:_
|
57
60
|
|
58
61
|
```yml
|
59
62
|
markup_presets:
|
@@ -81,29 +84,28 @@ The `default` preset will be used if none is specified. A preset name can't cont
|
|
81
84
|
|
82
85
|
For images that are different sizes on different screens (most images), use a width-based srcset
|
83
86
|
(which is the default). Specify a `widths` setting (or don't, for the default set), and optionally
|
84
|
-
the `sizes` and `size` settings.
|
87
|
+
the `sizes` and `size` settings.
|
85
88
|
|
86
89
|
Use a multiplier-based srcset when the image will always be the same size, regardless of screen
|
87
90
|
width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratios` and `base_width`.
|
88
91
|
|
89
92
|
### Settings reference
|
90
93
|
|
91
|
-
|
94
|
+
- **Markup format**
|
92
95
|
|
93
|
-
|
96
|
+
_Format:_ `markup: (setting)`
|
94
97
|
|
95
|
-
|
98
|
+
_Default_: `auto`
|
96
99
|
|
97
100
|
Defines what format the generated text will take. They are documented [here]({{ site.baseurl }}/output).
|
98
101
|
|
99
|
-
|
100
102
|
* **Image Formats**
|
101
103
|
|
102
|
-
|
104
|
+
_Format:_ `format: [format1, format2, (...)]`
|
103
105
|
|
104
|
-
|
106
|
+
_Example:_ `format: [webp, original]`
|
105
107
|
|
106
|
-
|
108
|
+
_Default_: `original`
|
107
109
|
|
108
110
|
Array (yml sequence) of the image formats you'd like to generate, in decreasing order of
|
109
111
|
preference. Browsers will render the first format they find and understand, so **If you put jpg
|
@@ -111,37 +113,37 @@ width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratio
|
|
111
113
|
webp, you must have an imagemagick webp delegate installed. (Most package managers just name it
|
112
114
|
'webp')
|
113
115
|
|
114
|
-
|
115
|
-
list by running `$ convert --version
|
116
|
+
_Supported formats are anything which imagemagick supports, and has an installed delegate. See a
|
117
|
+
list by running `$ convert --version`_
|
116
118
|
|
117
119
|
* **Widths**
|
118
120
|
|
119
|
-
|
121
|
+
_Format:_ `widths: [integer, integer, (...)]`
|
120
122
|
|
121
|
-
|
123
|
+
_Example:_ `widths: [600, 800, 1200]`
|
122
124
|
|
123
|
-
|
125
|
+
_Default_: `[400, 600, 800, 1000]`
|
124
126
|
|
125
127
|
Array of image widths to generate, in pixels. For use when you want a width-based srcset
|
126
128
|
(`srcset="img.jpg 800w, img2.jpg 1600w"`).
|
127
129
|
|
128
130
|
* **Media_widths**
|
129
131
|
|
130
|
-
|
132
|
+
_Format:_
|
131
133
|
|
132
134
|
```yml
|
133
135
|
media_widths:
|
134
136
|
(media preset name): [integer, integer, (...)]
|
135
137
|
```
|
136
138
|
|
137
|
-
|
139
|
+
_Example:_
|
138
140
|
|
139
141
|
```yml
|
140
142
|
media_widths:
|
141
143
|
mobile: [400, 600, 800]
|
142
144
|
```
|
143
145
|
|
144
|
-
|
146
|
+
_Default:_ Widths setting
|
145
147
|
|
146
148
|
If you are using art direction, there is no sense in generating desktop-size files for your mobile
|
147
149
|
image. You can specify sets of widths to associate with given media queries. If not specified,
|
@@ -149,7 +151,7 @@ width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratio
|
|
149
151
|
|
150
152
|
* **Sizes**
|
151
153
|
|
152
|
-
|
154
|
+
_Format:_
|
153
155
|
|
154
156
|
```yml
|
155
157
|
sizes:
|
@@ -157,7 +159,7 @@ width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratio
|
|
157
159
|
(...)
|
158
160
|
```
|
159
161
|
|
160
|
-
|
162
|
+
_Example:_
|
161
163
|
|
162
164
|
```yml
|
163
165
|
sizes:
|
@@ -170,7 +172,7 @@ width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratio
|
|
170
172
|
image will be (on the screen) when a given media query is true. CSS dimensions can be given in
|
171
173
|
`px`, `em`, or `vw`. To be used along with a width-based srcset.
|
172
174
|
|
173
|
-
Provide these in order of most restrictive to least restrictive. The browser will choose the
|
175
|
+
Provide these in order of most restrictive to least restrictive. The browser will choose the
|
174
176
|
first one with an applicable media query.
|
175
177
|
|
176
178
|
You don't have to provide a sizes attribute at all. If you don't, the browser will assume the
|
@@ -178,17 +180,17 @@ width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratio
|
|
178
180
|
|
179
181
|
* **Size**
|
180
182
|
|
181
|
-
|
183
|
+
_Format:_ `size: (CSS Dimension)`
|
182
184
|
|
183
|
-
|
185
|
+
_Example:_ `size: 80vw`
|
184
186
|
|
185
187
|
Unconditional `sizes` setting, to be supplied either alone or after all conditional sizes.
|
186
188
|
|
187
189
|
* **Pixel Ratios**
|
188
190
|
|
189
|
-
|
191
|
+
_Format:_ `pixel_ratios: [number, number, number (...)]`
|
190
192
|
|
191
|
-
|
193
|
+
_Example:_ `pixel_ratios: [1, 1.5, 2]`
|
192
194
|
|
193
195
|
Array of images to construct, given in multiples of the base width. If you set this, you must also
|
194
196
|
give a `base_width`.
|
@@ -197,26 +199,79 @@ width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratio
|
|
197
199
|
|
198
200
|
* **Base Width**
|
199
201
|
|
200
|
-
|
202
|
+
_Format:_ `base_width: integer`
|
201
203
|
|
202
|
-
|
204
|
+
_Example:_ `base_width: 100`
|
203
205
|
|
204
206
|
When using pixel ratios, you must supply a base width. This sets how wide the 1x image should be.
|
205
207
|
|
208
|
+
* **Crop & Media Crop**
|
209
|
+
|
210
|
+
_Format:_
|
211
|
+
|
212
|
+
```yml
|
213
|
+
crop: (geometery)
|
214
|
+
media_crop:
|
215
|
+
(media_preset): (geometry)
|
216
|
+
(media_preset): (geometry)
|
217
|
+
(...)
|
218
|
+
```
|
219
|
+
|
220
|
+
_Example:_
|
221
|
+
|
222
|
+
```yml
|
223
|
+
crop: 16:9
|
224
|
+
media_crop:
|
225
|
+
tablet: 3:2
|
226
|
+
mobile: 1:1
|
227
|
+
```
|
228
|
+
|
229
|
+
**Check the [ installation guide ](installation) before using this feature.**
|
230
|
+
|
231
|
+
Crop geometry, given either generally or for specific media presets. The hierarchy is:
|
232
|
+
`tag argument` > `media_crop:` > `crop:`.
|
233
|
+
|
234
|
+
This setting accepts the same arguments as the `crop geometry` [tag parameter](usage).
|
235
|
+
|
236
|
+
|
237
|
+
* **Gravity & Media_gravity**
|
238
|
+
|
239
|
+
```yml
|
240
|
+
crop: (gravity)
|
241
|
+
media_crop:
|
242
|
+
(media_preset): (gravity)
|
243
|
+
(media_preset): (gravity)
|
244
|
+
(...)
|
245
|
+
```
|
246
|
+
|
247
|
+
_Example:_
|
248
|
+
|
249
|
+
```yml
|
250
|
+
crop: north
|
251
|
+
media_crop:
|
252
|
+
tablet: east
|
253
|
+
mobile: southwest
|
254
|
+
```
|
255
|
+
|
256
|
+
Crop gravity, given either generally or for specific media presets. The hierarchy is:
|
257
|
+
`tag argument` > `media_crop:` > `crop:` > `center` (default).
|
258
|
+
|
259
|
+
This setting accepts the same arguments as the `crop gravity` [tag parameter](usage).
|
260
|
+
|
206
261
|
* **Quality**
|
207
262
|
|
208
|
-
|
263
|
+
_Format:_ `quality: 0 <= integer <= 100`
|
209
264
|
|
210
|
-
|
265
|
+
_Example:_ `quality: 80`
|
211
266
|
|
212
|
-
|
267
|
+
_Default:_ `75`
|
213
268
|
|
214
269
|
This allows you to specify an image compression level for all image formats (where it makes sense,
|
215
270
|
anyway). The next option allows you to set them per format.
|
216
271
|
|
217
272
|
* **Format Quality**
|
218
273
|
|
219
|
-
|
274
|
+
_Format:_
|
220
275
|
|
221
276
|
```yml
|
222
277
|
format_quality:
|
@@ -224,7 +279,7 @@ width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratio
|
|
224
279
|
(...)
|
225
280
|
```
|
226
281
|
|
227
|
-
|
282
|
+
_Example:_
|
228
283
|
|
229
284
|
```
|
230
285
|
format_quality:
|
@@ -233,16 +288,16 @@ width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratio
|
|
233
288
|
webp: 55
|
234
289
|
```
|
235
290
|
|
236
|
-
|
291
|
+
_Default:_ quality setting (above)
|
237
292
|
|
238
293
|
This allows you to specify quality settings for various image formats, allowing you to take
|
239
294
|
advantage of webp's better compression algorithm without trashing your jpg images (for example).
|
240
295
|
If you don't give a setting for a particular format it'll fall back to the `quality` setting
|
241
|
-
above, and if you don't set
|
296
|
+
above, and if you don't set _that_ it'll default to 75.
|
242
297
|
|
243
298
|
* **HTML Attributes**
|
244
299
|
|
245
|
-
|
300
|
+
_Format:_
|
246
301
|
|
247
302
|
```yml
|
248
303
|
attributes:
|
@@ -250,7 +305,7 @@ width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratio
|
|
250
305
|
(...)
|
251
306
|
```
|
252
307
|
|
253
|
-
|
308
|
+
_Example:_
|
254
309
|
|
255
310
|
```yml
|
256
311
|
attributes:
|
@@ -258,49 +313,49 @@ width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratio
|
|
258
313
|
picture: 'class="even-cooler"'
|
259
314
|
```
|
260
315
|
|
261
|
-
HTML attributes you would like to add.
|
316
|
+
HTML attributes you would like to add. The same arguments are available here as in the liquid
|
262
317
|
tag: HTML element names, `alt:`, `link:`, and `parent:`. Unescaped double quotes cause problems
|
263
318
|
with yml, so it's recommended to surround them with single quotes.
|
264
319
|
|
265
320
|
* **Fallback Width**
|
266
321
|
|
267
|
-
|
322
|
+
_Format:_ `fallback_width: (integer)`
|
268
323
|
|
269
|
-
|
324
|
+
_Example:_ `fallback_width: 800`
|
270
325
|
|
271
|
-
|
326
|
+
_Default_: `800`
|
272
327
|
|
273
328
|
Width of the fallback image.
|
274
329
|
|
275
330
|
* **Fallback Format**
|
276
331
|
|
277
|
-
|
332
|
+
_Format:_ `fallback_format: (format)`
|
278
333
|
|
279
|
-
|
334
|
+
_Example:_ `fallback_format: jpg`
|
280
335
|
|
281
|
-
|
336
|
+
_Default_: `original`
|
282
337
|
|
283
338
|
Format of the fallback image
|
284
339
|
|
285
340
|
* **Source Image Link**
|
286
341
|
|
287
|
-
|
342
|
+
_Format:_ `link_source: (true|false)`
|
288
343
|
|
289
|
-
|
344
|
+
_Example:_ `link_source: true`
|
290
345
|
|
291
|
-
|
346
|
+
_Default:_ `false`
|
292
347
|
|
293
348
|
Surround image with a link to the original source file. Your source image directory must be
|
294
349
|
published as part of the compiled site. If you run into weird issues with the output, see
|
295
350
|
the [notes]({{ site.baseurl }}/notes).
|
296
351
|
|
297
352
|
* **Nomarkdown override**
|
298
|
-
|
299
|
-
*Format:* `nomarkdown: (true|false)`
|
300
353
|
|
301
|
-
|
354
|
+
_Format:_ `nomarkdown: (true|false)`
|
355
|
+
|
356
|
+
_Example:_ `nomarkdown: false`
|
302
357
|
|
303
|
-
|
358
|
+
_Default:_ `nil`
|
304
359
|
|
305
360
|
Hard setting for `{::nomarkdown}` tags, overrides both autodetection and the global setting in
|
306
|
-
`_config.yml`. See the [notes]({{ site.baseurl }}/notes) for a detailed explanation.
|
361
|
+
`_config.yml`. See the [notes]({{ site.baseurl }}/notes) for a detailed explanation.
|