jekyll_picture_tag 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/.travis.yml +11 -0
  4. data/Gemfile +2 -2
  5. data/Rakefile +28 -0
  6. data/contributing.md +67 -0
  7. data/docs/examples/_config.yml +10 -0
  8. data/{examples → docs/examples}/_data/picture.yml +39 -19
  9. data/docs/examples/post.md +46 -0
  10. data/docs/global_configuration.md +115 -0
  11. data/docs/installation.md +30 -0
  12. data/docs/migration.md +178 -0
  13. data/docs/notes.md +85 -0
  14. data/docs/presets.md +407 -0
  15. data/docs/readme.md +23 -0
  16. data/docs/usage.md +131 -0
  17. data/jekyll-picture-tag.gemspec +3 -12
  18. data/jekyll_picture_tag.gemspec +8 -3
  19. data/lib/jekyll-picture-tag.rb +5 -3
  20. data/lib/jekyll_picture_tag.rb +45 -42
  21. data/lib/jekyll_picture_tag/defaults/global.yml +0 -3
  22. data/lib/jekyll_picture_tag/defaults/presets.yml +1 -0
  23. data/lib/jekyll_picture_tag/generated_image.rb +60 -39
  24. data/lib/jekyll_picture_tag/img_uri.rb +55 -0
  25. data/lib/jekyll_picture_tag/instructions.rb +1 -102
  26. data/lib/jekyll_picture_tag/instructions/configuration.rb +30 -74
  27. data/lib/jekyll_picture_tag/instructions/html_attributes.rb +18 -27
  28. data/lib/jekyll_picture_tag/instructions/preset.rb +14 -3
  29. data/lib/jekyll_picture_tag/instructions/set.rb +61 -0
  30. data/lib/jekyll_picture_tag/instructions/tag_parser.rb +80 -23
  31. data/lib/jekyll_picture_tag/output_formats.rb +1 -1
  32. data/lib/jekyll_picture_tag/output_formats/{basics.rb → basic.rb} +24 -19
  33. data/lib/jekyll_picture_tag/output_formats/data_attributes.rb +2 -2
  34. data/lib/jekyll_picture_tag/output_formats/direct_url.rb +1 -3
  35. data/lib/jekyll_picture_tag/output_formats/img.rb +4 -4
  36. data/lib/jekyll_picture_tag/output_formats/naked_srcset.rb +5 -4
  37. data/lib/jekyll_picture_tag/output_formats/picture.rb +6 -16
  38. data/lib/jekyll_picture_tag/output_formats/readme.md +8 -15
  39. data/lib/jekyll_picture_tag/router.rb +98 -0
  40. data/lib/jekyll_picture_tag/source_image.rb +15 -23
  41. data/lib/jekyll_picture_tag/srcsets.rb +1 -1
  42. data/lib/jekyll_picture_tag/srcsets/{basics.rb → basic.rb} +22 -13
  43. data/lib/jekyll_picture_tag/srcsets/pixel_ratio.rb +6 -11
  44. data/lib/jekyll_picture_tag/srcsets/width.rb +3 -11
  45. data/lib/jekyll_picture_tag/utils.rb +32 -49
  46. data/lib/jekyll_picture_tag/version.rb +1 -1
  47. data/readme.md +70 -70
  48. metadata +97 -16
  49. data/bin/console +0 -14
  50. data/bin/setup +0 -7
  51. data/examples/_config.yml +0 -4
  52. data/examples/post.md +0 -18
@@ -0,0 +1,178 @@
1
+ # Migrating from versions < 1.0
2
+
3
+ This document details the changes from previous versions (Everything before 1.0), and how to migrate
4
+ an existing site to the new version. It won't be updated to reflect new features -- it simply
5
+ describes how to get your site working with the new version.
6
+
7
+ ## Changes from previous versions:
8
+
9
+ - The default output formats are bone-stock HTML. Picturefill, as of version 3, no longer requires
10
+ special markup, so it remains compatible. Other javascript image solutions are supported with
11
+ the `data_` selection of markup formats. Interchange support is removed, though adding it again
12
+ is not difficult if there is demand for it.
13
+ - There are now 2 basic markup formats to choose from: `<source>` tags within a `<picture>`, and a
14
+ single `<img>` tag. If markup is set to 'auto', or if it is not set at all, the plugin will
15
+ automatically determine which is most appropriate. These formats also have `data_` counterparts
16
+ (i.e. `data_auto`), which accomplish the same thing except setting respective data-attributes
17
+ to allow for lazy loading and such.
18
+ - There are also 2 srcset formats: one which supplies image width, and another which supplies
19
+ multiples (pixel ratios) of the base size.
20
+ - Source Keys are replaced by media query presets, which can also be used to create the 'sizes'
21
+ attribute.
22
+ - Jekyll Picture Tag no longer accepts height arguments, and will no longer crop images for you.
23
+ Aspect ratio will always be maintained.
24
+ - Multiple image widths are now supported, which will be used to create a corresponding srcset.
25
+ - Multiple image formats are now possible, including webp.
26
+ - PictureTag can now generate sizes attributes.
27
+ - Configuration takes a very different format. It should be simpler to write your config than the
28
+ old version, and migrating to it should not be difficult. Instead of creating individual source
29
+ keys, you supply an array of widths you'd like to construct. You can also supply an array (yaml
30
+ sequence) of formats, including 'original'.
31
+ - Only global settings are placed in `_config.yml`. Presets are moved to `_data/picture.yml`.
32
+
33
+ ## Migration
34
+
35
+ ### Liquid Tags
36
+
37
+ Previous tag syntax has been extended, but backwards compatibility (and behaviour of previous
38
+ versions) is maintained.
39
+
40
+ `{% picture img.jpg (implicit attributes) --(argument) (explicit attributes) %}`
41
+
42
+ Implicit attributes are the old way. They are specified after the last source image, and before any
43
+ explicit attributes (if they are included). These attributes are applied to the `<img>` tag, as in
44
+ previous versions.
45
+
46
+ Explicit attributes are the new way, documented in the readme. It is possible to use a mix of both,
47
+ though I'm not sure why you would want to.
48
+
49
+ There is one instance I can think of where you will have to change your tags:
50
+
51
+ - You use art direction with more than one different preset.
52
+ - These presets have source keys of the same name.
53
+ - These source keys have different associated media queries.
54
+
55
+ If all of the above are true, you will either have to pick one media query which works for both, or
56
+ rename one of them and change it everywhere it's used.
57
+
58
+ Another trouble spot will be CSS; your output markup may change, meaning your CSS selectors may stop
59
+ working.
60
+
61
+ Outside of those situations, and provided you have created media_presets to match your old source
62
+ keys, your existing tags should keep working. If they don't, it's a bug. Please report it.
63
+
64
+ ### Configuration
65
+
66
+ The new configuration is described in the readme so I won't document it here, but I will show an old
67
+ config alongside an equivalent new one.
68
+
69
+ Example old configuration:
70
+
71
+ ```yml
72
+ # _config.yml
73
+
74
+ picture:
75
+ source: assets/images/_fullsize
76
+ output: generated
77
+ markup: picture
78
+ presets:
79
+ # Full width pictures
80
+ default:
81
+ ppi: [1, 1.5]
82
+ attr:
83
+ class: blog-full
84
+ itemprop: image
85
+ source_lrg:
86
+ media: "(min-width: 40em)"
87
+ width: 700
88
+ source_med:
89
+ media: "(min-width: 30em)"
90
+ width: 450
91
+ source_default:
92
+ width: 350
93
+ height: 200
94
+ # Half width pictures
95
+ half:
96
+ ppi: [1, 1.5]
97
+ attr:
98
+ data-location: "{{location}}"
99
+ data-active: nil
100
+ source_lrg:
101
+ media: "(min-width: 40em)"
102
+ width: 400
103
+ source_med:
104
+ media: "(min-width: 30em)"
105
+ width: 250
106
+ source_default:
107
+ width: 350
108
+ # Self-set resolution sources. Useful if you don't want a 1:1 image size to dppx ratio.
109
+ gallery:
110
+ source_wide_hi:
111
+ media: "(min-width: 40em) and (min-resolution: 1.5dppx)"
112
+ width: 900
113
+ height: 600
114
+ source_wide:
115
+ media: "(min-width: 40em)"
116
+ width: 600
117
+ height: 400
118
+ source_default:
119
+ width: 250
120
+ height: 250
121
+ ```
122
+
123
+ Equivalent new configuration:
124
+
125
+ ```yml
126
+ # _config.yml
127
+
128
+ picture:
129
+ source: assets/images/_fullsize
130
+ output: generated
131
+ ```
132
+
133
+ ```yml
134
+ # _data/picture.yml
135
+
136
+ # Media presets are named media queries. To maintain compatibility with your tags, you need to
137
+ # create presets of the same name as your old source keys. There is no limit to how many of them you
138
+ # can have, so you're free to create additional new ones with better names to use going forward.
139
+ media_presets:
140
+ source_lrg: '(min-width: 40em)'
141
+ source_med: '(min-width: 30em)'
142
+ source_wide_hi: "(min-width: 40em) and (min-resolution: 1.5dppx)"
143
+ source_wide: "(min-width: 40em)"
144
+
145
+ markup_presets:
146
+ # You can't specify both widths and pixel ratios anymore. Choose one.
147
+ # Full width pictures, width-based srcset
148
+ default:
149
+ markup: picture
150
+ widths: [350, 450, 700]
151
+ attributes:
152
+ picture: 'class="blog-full" itemprop="image"'
153
+
154
+ # Full width pictures, multiplier based srcset
155
+ default-ppi:
156
+ markup: picture
157
+ base_width: 350
158
+ pixel_ratios: [1, 1.5]
159
+ attributes:
160
+ picture: 'class="blog-full" itemprop="image"'
161
+
162
+ # Half width pictures
163
+ half:
164
+ widths: [250, 350, 400]
165
+ attributes:
166
+ picture: 'data-location="{{location}}" data-active="nil"'
167
+
168
+ # Note you can't set heights anymore. You'll have to crop your images either ahead of time, or
169
+ # do it with CSS.
170
+ #
171
+ # You have to use arrays for widths, even if only specifying a single value. There's no reason you
172
+ # can't add more.
173
+ gallery:
174
+ widths: [250]
175
+ media_widths:
176
+ source_wide_hi: [900]
177
+ source_wide: [600]
178
+ ```
@@ -0,0 +1,85 @@
1
+ # Notes and FAQ
2
+
3
+ ## Extra {::nomarkdown} tags or mangled HTML?
4
+
5
+ **TLDR up front:** There's a bug involving `<picture>` tags wrapped in `<a>` tags which is not in my
6
+ power to fix.
7
+
8
+ * If you're getting extra `{::nomarkdown}` tags floating around your images, add `nomarkdown: false`
9
+ to either the relevant preset or under `picture` in `_config.yml`.
10
+
11
+ * If you're getting mangled HTML when trying to wrap images with anchor tags, add `nomarkdown: true`
12
+ to the preset.
13
+
14
+ #### What's going on here:
15
+
16
+ Kramdown is Jekyll's default markdown parser. Kramdown gets grumpy when you give it a block level
17
+ element (such as a `<picture>`) surrounded by a span level element (such as an `<a>`), and horribly
18
+ mangles it. The fix for this is to tell Kramdown to chill with a `{::nomarkdown}..{:/nomarkdown}`
19
+ wrapper.
20
+
21
+ Jekyll Picture Tag can be called from many different places: a markdown file, an HTML file, an HTML
22
+ layout for a markdown file, and an HTML include, to name a few. JPT tries its best to determine
23
+ whether its output will be parsed by Kramdown or not, but Jekyll itself doesn't make this
24
+ particularly easy which results in some false positives. (The one I'm most aware of is when a
25
+ markdown file uses an HTML layout which includes a picture tag.)
26
+
27
+ Unfortunately, I don't see an easy way to fix this. We've gotten this far mostly by trial and error.
28
+ I'll continue to work on improving the autodetection, but you can override this behavior explicitly.
29
+
30
+ #### The fix:
31
+
32
+ By default, JPT will add a `{::nomarkdown}` tag if all of the following are true:
33
+ * It thinks it's called from a markdown page
34
+ * The image will be wrapped in an anchor tag (i.e. `link_source_image:` or a `--link` parameter)
35
+ * This behavior hasn't been explicitly disabled.
36
+
37
+ You can disable nomarkdown tags globally by setting `nomarkdown: false` under the `picture:` key in
38
+ `_config.yml`.
39
+
40
+ You can enable or disable markdown tags per preset by adding `nomarkdown: true|false` to them.
41
+ **This setting overrides everything else, both JPT autodetection and the global setting.**
42
+
43
+ ## Input checking
44
+
45
+ Jekyll Picture Tag is very trusting. It doesn't do much checking of your inputs, and it does not
46
+ fail gracefully if you for example pass it a string when it expects an array. It's on the to-do
47
+ list, but for now if you get cryptic errors then double-check your settings and tag arguments.
48
+
49
+ ## Git LFS
50
+
51
+ Putting this here because it bit me: If you want to use git LFS, make sure that your hosting
52
+ provider makes those images available during the build process. Netlify, for example, does not. You
53
+ won't find this out until you have gone through the entire migration process and try to deploy for
54
+ the first time.
55
+
56
+ ## Lazy Loading, and other javascript related tomfoolery
57
+
58
+ Use one of the `data_` output formats and something like
59
+ [LazyLoad](https://github.com/verlok/lazyload). The 'lazy' preset in the example config will work.
60
+
61
+ ## PictureFill
62
+
63
+ [Picturefill](http://scottjehl.github.io/picturefill/) version 3 no longer requires special markup.
64
+ Standard outputs should be compatible.
65
+
66
+ ## Managing Generated Images
67
+
68
+ Jekyll Picture Tag creates resized versions of your images when you build the site. It uses a smart
69
+ caching system to speed up site compilation, and re-uses images as much as possible. Filenames
70
+ take the following format:
71
+
72
+ `(original filename without extension)-(width)-(source hash).(appropriate extension)`
73
+
74
+ Source hash is the first 5 characters of an md5 checksum of the source image.
75
+
76
+ Try to use a base image that is larger than the largest resized image you need. Jekyll Picture Tag
77
+ will warn you if a base image is too small, and won't upscale images.
78
+
79
+ By specifying a `source` directory that is ignored by Jekyll you can prevent huge base images from
80
+ being copied to the compiled site. For example, `source: assets/images/_fullsize` and `output:
81
+ generated` will result in a compiled site that contains resized images but not the originals. Note
82
+ that this will break source image linking, if you wish to enable it. (Can't link to images that
83
+ aren't public!)
84
+
85
+ The `output` directory is never deleted by Jekyll. You may want to empty it once in awhile, to clear out unused images.
@@ -0,0 +1,407 @@
1
+ # Writing Presets
2
+
3
+ Presets are stored in `_data/picture.yml`, to avoid cluttering `_config.yml`. You will have to
4
+ create this file, and probably the `_data/` directory as well.
5
+
6
+ All settings are optional, moderately sensible defaults have been implemented.
7
+
8
+ ## Required Knowledge
9
+
10
+ If you don't understand responsive images, you won't know what to do with these settings. Jekyll
11
+ Picture tag is basically a programmatic implementation of the [MDN Responsive Images
12
+ guide](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images).
13
+
14
+ If you don't know the difference between resolution switching and art direction, stop now and read it
15
+ in detail. Ideally, play around with a basic HTML file, a few test images, and a few different
16
+ browser widths until you understand it.
17
+
18
+ ## Example settings
19
+
20
+ A more thorough example can be found under `docs/examples/_data/picture.yml`.
21
+
22
+ ```yml
23
+
24
+ # _data/picture.yml
25
+
26
+ media_presets:
27
+ wide_desktop: 'min-width: 1801px'
28
+ desktop: 'max-width: 1800px'
29
+ wide_tablet: 'max-width: 1200px'
30
+ tablet: 'max-width: 900px'
31
+ mobile: 'max-width: 600px'
32
+
33
+ markup_presets:
34
+ default:
35
+ formats: [webp, original]
36
+ widths: [200, 400, 800, 1600]
37
+ media_widths:
38
+ mobile: [200, 400, 600]
39
+ tablet: [400, 600, 800]
40
+ size: 800px
41
+ sizes:
42
+ mobile: 100vw
43
+ desktop: 60vw
44
+ attributes:
45
+ picture: 'class="awesome" data-volume="11"'
46
+ img: 'class="some-other-class"'
47
+
48
+ icon:
49
+ base-width: 20
50
+ pixel_ratios: [1, 1.5, 2]
51
+
52
+ lazy:
53
+ markup: data_auto
54
+ formats: [webp, original]
55
+ widths: [200, 400, 600, 800]
56
+ noscript: true
57
+ attributes:
58
+ img: class="lazy"
59
+
60
+ ```
61
+
62
+ ## Media Presets
63
+
64
+ *Format:*
65
+
66
+ ```yml
67
+ media_presets:
68
+ (name): (css media query)
69
+ (name): (css media query)
70
+ (name): (css media query)
71
+ (...)
72
+
73
+ ```
74
+
75
+ *Example:*
76
+
77
+ ```yml
78
+ media_presets:
79
+ desktop: 'min-width: 1200px'
80
+ ```
81
+
82
+ These are named media queries for use in a few different places.
83
+
84
+ Keys are names by which you can refer to the media queries supplied as their respective values.
85
+ These are used for specifying alternate source images in your liquid tag, and for building the
86
+ 'sizes' attribute within your presets. Quotes are required around the media
87
+ queries, because yml gets confused by free colons.
88
+
89
+ ## Markup Presets
90
+
91
+ *Format:*
92
+
93
+ ```yml
94
+ markup_presets:
95
+ (name):
96
+ (option): (setting)
97
+ (option): (setting)
98
+ (option): (setting)
99
+ (...)
100
+ (another name):
101
+ (option): (setting)
102
+ (option): (setting)
103
+ (option): (setting)
104
+ (...)
105
+ ```
106
+
107
+ *Example:*
108
+
109
+ ```yml
110
+ markup_presets:
111
+ default:
112
+ formats: [webp, original]
113
+ widths: [200, 400, 800, 1600]
114
+ link_source: true
115
+ lazy:
116
+ markup: data_auto
117
+ widths: [200, 400, 800, 1600]
118
+ link_source: true
119
+ noscript: true
120
+ ```
121
+
122
+ These are the 'presets' from previous versions, with different structure. Each entry is a
123
+ pre-defined collection of settings to build a given chunk of HTML and its respective images. You
124
+ can select one as the first argument given to the tag:
125
+
126
+ `{% picture my-preset image.jpg %}`
127
+
128
+ The `default` preset will be used if none is specified. A preset name can't contain the `.`, `:`,
129
+ or `/` characters.
130
+
131
+ #### A Note on srcsets, for the bad kids who didn't do the required reading.
132
+
133
+ There are 2 srcset formats, one based on providing widths, the other based on providing multipliers.
134
+
135
+ Width based srcsets look like this: `srcset="img.jpg 600w, img2.jpg 800w, img3.jpg 1000w"`. The
136
+ `(number)w` tells the browser how wide that image file is. Browsers are smart, they know their
137
+ device's pixel ratio, so in combination with the sizes attribute (if given, otherwise it assumes the
138
+ image will be 100vw) they can select the best-fitting image for the space it will fill on the screen. This is generally the one you want to use.
139
+
140
+ Multiplier based srcsets look like this: `srcset="img.jpg 1x, img2.jpg 1.5x, img3.jpg 3x"`. The
141
+ browser is less smart here; it looks at its own device's pixel ratio, compares it to the given
142
+ multiplier, and picks the closest one. It doesn't consider anything else at all. Multiplier based
143
+ srcsets are best used when the image will always be the same size, on all screen sizes.
144
+
145
+ To use a width based srcset in a preset, specify a `widths` setting (or don't, for the default), and
146
+ optionally the `sizes` and `size` settings.
147
+
148
+ To use a multiplier based srcset, set `pixel_ratios` and `base_width`.
149
+
150
+ ### Markup preset settings
151
+
152
+ * **Markup format**
153
+
154
+ *Format:* `markup: (setting)`
155
+
156
+ *Default*: `auto`
157
+
158
+ Defines what format the generated HTML will take. Here are your options:
159
+
160
+ * `picture`: `<picture>` element surrounding a `<source>` tag for each required srcset, and a
161
+ fallback `<img>`.
162
+ * `img`: output a single `<img>` tag with a `srcset` entry.
163
+ * `auto`: Supply an img tag when you have only one srcset, otherwise supply a picture tag.
164
+ * `data_picture`, `data_img`, `data_auto`: Analogous to their counterparts,
165
+ but instead of `src`, `srcset`, and `sizes`, you get `data-src`, `data-srcset`, and
166
+ `data-sizes`. This allows you to use javascript for things like [lazy loading](https://github.com/verlok/lazyload)
167
+ * `direct_url`: Generates an image and returns only its url. Uses `fallback_` properties (width
168
+ and format)
169
+ * `naked_srcset`: Builds a srcset and nothing else (not even the surrounding quotes). Useful with
170
+ libraries requiring more complex or customized markup. Note that the (image) `format` setting
171
+ must still be an array, even if you can only give it one value.
172
+
173
+ * **Image Formats**
174
+
175
+ *Format:* `format: [format1, format2, (...)]`
176
+
177
+ *Example:* `format: [webp, original]`
178
+
179
+ *Default*: `original`
180
+
181
+ *Supported formats are anything which imagemagick supports, including the
182
+ following:*
183
+ * jpg/jpeg
184
+ * png
185
+ * gif
186
+ * webp
187
+ * jxr
188
+ * jp2
189
+
190
+ Array (yml sequence) of the image formats you'd like to generate, in decreasing order of
191
+ preference. Browsers will render the first format they find and understand, so **If you put jpg
192
+ before webp, your webp images will never be used**. `original` does what you'd expect. To supply
193
+ webp, you must have an imagemagick webp delegate installed. (Most package managers just name it
194
+ 'webp')
195
+
196
+ * **widths**
197
+
198
+ *Format:* `widths: [integer, integer, (...)]`
199
+
200
+ *Example:* `widths: [600, 800, 1200]`
201
+
202
+ *Default*: `[400, 600, 800, 1000]`
203
+
204
+ Array of image widths to generate, in pixels. For use when you want a size-based srcset
205
+ (`srcset="img.jpg 800w, img2.jpg 1600w"`).
206
+
207
+ * **media_widths**
208
+
209
+ *Format:*
210
+
211
+ ```yml
212
+ media_widths:
213
+ (media preset name): [integer, integer, (...)]
214
+ ```
215
+
216
+ *Example:*
217
+
218
+ ```yml
219
+ media_widths:
220
+ mobile: [400, 600, 800]
221
+ ```
222
+
223
+ *Default:* Widths setting
224
+
225
+ If you are using art direction, there is no sense in generating desktop-size files for your mobile
226
+ image. You can specify sets of widths to associate with given media queries. If not specified,
227
+ will use `widths` setting.
228
+
229
+ * **Fallback Width**
230
+
231
+ *Format:* `fallback_width: (integer)`
232
+
233
+ *Example:* `fallback_width: 800`
234
+
235
+ *Default*: `800`
236
+
237
+ Width of the fallback image.
238
+
239
+ * **Fallback Image**
240
+
241
+ *Format:* `fallback_format: (format)`
242
+
243
+ *Example:* `fallback_format: jpg`
244
+
245
+ *Default*: `original`
246
+
247
+ Format of the fallback image
248
+
249
+ * **Sizes**
250
+
251
+ *Format:*
252
+ ```yml
253
+ sizes:
254
+ (media preset): (CSS dimension)
255
+ (media preset): (CSS dimension)
256
+ (media preset): (CSS dimension)
257
+ (...)
258
+ ```
259
+
260
+ *Example:*
261
+ ```yml
262
+ sizes:
263
+ mobile: 80vw
264
+ tablet: 60vw
265
+ desktop: 900px
266
+ ```
267
+
268
+ Conditional sizes, used to construct the `sizes=` HTML attribute telling the browser how wide your
269
+ image will be (on the screen) when a given media query is true. CSS dimensions can be given in
270
+ `px`, `em`, or `vw`. To be used along with a width based srcset.
271
+
272
+ Provide these in order of most restrictive to least restrictive. The browser will choose the
273
+ first one with an applicable media query.
274
+
275
+ You don't have to provide a sizes attribute at all. If you don't, the browser will assume the
276
+ image is 100% the width of the viewport.
277
+
278
+ The same sizes attribute is used for every source tag in a given picture tag. This causes some
279
+ redundant markup, specifying sizes for situations when an image will never be rendered, but it
280
+ keeps things a bit simpler.
281
+
282
+ * **Size**
283
+
284
+ *Format:* `size: (CSS Dimension)`
285
+
286
+ *Example:* `size: 80vw`
287
+
288
+ Unconditional image width to give the browser (by way of the html sizes attribute), to be supplied
289
+ either alone or after all conditional sizes.
290
+
291
+ * **Pixel Ratios**
292
+
293
+ *Format:* `pixel_ratios: [number, number, number (...)]`
294
+
295
+ *Example:* `pixel_ratios: [1, 1.5, 2]`
296
+
297
+ Array of images to construct, given in multiples of the base width. If you set this, you must also
298
+ give a `base_width`.
299
+
300
+ Set this when you want a multiplier based srcset (example: `srcset="img.jpg 1x, img2.jpg 2x"`).
301
+
302
+ * **Base Width**
303
+
304
+ *Format:* `base_width: integer`
305
+
306
+ *Example:* `base_width: 100`
307
+
308
+ When using pixel ratios, you must supply a base width. This sets how wide the 1x image should be.
309
+
310
+ * **Quality**
311
+
312
+ *Format:* `quality: integer <= 100`
313
+
314
+ *Example:* `quality: 80`
315
+
316
+ *Default:* `75`
317
+
318
+ This allows you to specify an image compression level for all image formats (where it makes sense,
319
+ anyway). The next option allows you to set them per format.
320
+
321
+ * **Format Quality**
322
+
323
+ *Format:*
324
+
325
+ ```yml
326
+ format_quality:
327
+ (format): integer <= 100
328
+ (format): integer <= 100
329
+ (format): integer <= 100
330
+ (...)
331
+ ```
332
+
333
+ *Example:*
334
+
335
+ ```
336
+ format_quality:
337
+ jpg: 75
338
+ png: 65
339
+ webp: 55
340
+ ```
341
+
342
+ *Default:* quality setting (above)
343
+
344
+ This allows you to specify quality settings for various image formats, allowing you to take
345
+ advantage of webp's better compression algorithm without trashing your jpg images (for example).
346
+ If you don't give a setting for a particular format it'll fall back to the `quality` setting
347
+ above, and if you don't set *that* it'll default to 75.
348
+
349
+ * **HTML Attributes**
350
+
351
+ *Format:*
352
+
353
+ ```yml
354
+ attributes:
355
+ (element): '(attributes)'
356
+ (element): '(attributes)'
357
+ (element): '(attributes)'
358
+ (...)
359
+ ```
360
+
361
+ *Example:*
362
+
363
+ ```yml
364
+ attributes:
365
+ img: 'class="soopercool" data-awesomeness="11"'
366
+ picture: 'class="even-cooler"'
367
+ ```
368
+
369
+ HTML attributes you would like to add. The same arguments are available here as in the liquid
370
+ tag; element names, `alt:`, `url:`, and `parent:`. Unescaped double quotes cause problems with
371
+ yml, so it's recommended to surround them with single quotes.
372
+
373
+ * **Noscript**
374
+
375
+ *Format:* `noscript: (true|false)`
376
+
377
+ *Example:* `noscript: true`
378
+
379
+ *Default:* `false`
380
+
381
+ For use with the `data_` output formats. When true, will include a basic `img` fallback within a
382
+ `<noscript>` tag after the standard html. This allows you to use lazy loading or other javascript
383
+ image tools, without breaking all of your images for non-javascript-enabled users.
384
+
385
+ * **Source Image Linking**
386
+
387
+ *Format:* `link_source: (true|false)`
388
+
389
+ *Example:* `link_source: true`
390
+
391
+ *Default:* `false`
392
+
393
+ Surround image with a link to the original source file. Your source image directory must be
394
+ published as part of the compiled site. If you run into weird issues with the output, see
395
+ [notes](notes.md).
396
+
397
+ * **Nomarkdown override**
398
+
399
+ *Format:* `nomarkdown: (true|false)`
400
+
401
+ *Example:* `nomarkdown: false`
402
+
403
+ *Default:* `nil`
404
+
405
+ Hard setting for `{::nomarkdown}` tags, overrides both autodetection and the global setting in
406
+ `_config.yml`. See [notes](notes.md) for a detailed explanation.
407
+