jekyll_picture_tag 1.9.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.travis.yml +4 -7
  4. data/Dockerfile +9 -0
  5. data/docs/Gemfile +4 -2
  6. data/docs/Gemfile.lock +186 -89
  7. data/docs/_config.yml +6 -10
  8. data/docs/devs/contributing/code.md +44 -0
  9. data/docs/devs/contributing/docs.md +13 -0
  10. data/docs/devs/contributing/index.md +15 -0
  11. data/docs/devs/contributing/setup.md +13 -0
  12. data/docs/devs/contributing/testing.md +41 -0
  13. data/docs/devs/index.md +7 -0
  14. data/docs/{releases.md → devs/releases.md} +35 -13
  15. data/docs/index.md +58 -36
  16. data/docs/users/configuration/cdn.md +35 -0
  17. data/docs/users/configuration/directories.md +34 -0
  18. data/docs/users/configuration/disable.md +24 -0
  19. data/docs/users/configuration/fast_build.md +28 -0
  20. data/docs/users/configuration/ignore_missing.md +23 -0
  21. data/docs/users/configuration/index.md +29 -0
  22. data/docs/users/configuration/kramdown_fix.md +20 -0
  23. data/docs/users/configuration/relative_urls.md +15 -0
  24. data/docs/users/configuration/suppress_warnings.md +16 -0
  25. data/docs/users/index.md +7 -0
  26. data/docs/users/installation.md +52 -0
  27. data/docs/users/liquid_tag/argument_reference/alternate_images.md +18 -0
  28. data/docs/users/liquid_tag/argument_reference/attributes.md +42 -0
  29. data/docs/users/liquid_tag/argument_reference/base_image.md +12 -0
  30. data/docs/users/liquid_tag/argument_reference/crop.md +48 -0
  31. data/docs/users/liquid_tag/argument_reference/link.md +16 -0
  32. data/docs/users/liquid_tag/argument_reference/preset.md +17 -0
  33. data/docs/users/liquid_tag/argument_reference/readme.md +9 -0
  34. data/docs/users/liquid_tag/examples.md +81 -0
  35. data/docs/users/liquid_tag/index.md +31 -0
  36. data/docs/users/notes/git_lfs.md +7 -0
  37. data/docs/users/notes/github_pages.md +5 -0
  38. data/docs/users/notes/html_attributes.md +5 -0
  39. data/docs/users/notes/index.md +6 -0
  40. data/docs/users/notes/input_checking.md +6 -0
  41. data/docs/users/notes/kramdown_bug.md +41 -0
  42. data/docs/users/notes/managing_images.md +21 -0
  43. data/docs/{migration.md → users/notes/migration.md} +0 -0
  44. data/docs/users/presets/cropping.md +61 -0
  45. data/docs/users/presets/default.md +23 -0
  46. data/docs/users/presets/examples.md +79 -0
  47. data/docs/users/presets/fallback_image.md +28 -0
  48. data/docs/users/presets/html_attributes.md +26 -0
  49. data/docs/users/presets/image_formats.md +21 -0
  50. data/docs/users/presets/image_quality.md +43 -0
  51. data/docs/users/presets/index.md +101 -0
  52. data/docs/users/presets/link_source.md +16 -0
  53. data/docs/users/presets/markup_formats/fragments.md +48 -0
  54. data/docs/users/presets/markup_formats/javascript_friendly.md +57 -0
  55. data/docs/users/presets/markup_formats/readme.md +43 -0
  56. data/docs/users/presets/markup_formats/standard_html.md +25 -0
  57. data/docs/users/presets/media_queries.md +36 -0
  58. data/docs/users/presets/nomarkdown_override.md +17 -0
  59. data/docs/users/presets/pixel_ratio_srcsets.md +32 -0
  60. data/docs/users/presets/width_height_attributes.md +34 -0
  61. data/docs/users/presets/width_srcsets.md +85 -0
  62. data/jekyll_picture_tag.gemspec +1 -1
  63. data/lib/jekyll_picture_tag.rb +1 -0
  64. data/lib/jekyll_picture_tag/cache.rb +3 -0
  65. data/lib/jekyll_picture_tag/cache/base.rb +59 -0
  66. data/lib/jekyll_picture_tag/cache/generated.rb +20 -0
  67. data/lib/jekyll_picture_tag/cache/source.rb +19 -0
  68. data/lib/jekyll_picture_tag/defaults/presets.yml +2 -0
  69. data/lib/jekyll_picture_tag/generated_image.rb +52 -41
  70. data/lib/jekyll_picture_tag/img_uri.rb +1 -0
  71. data/lib/jekyll_picture_tag/instructions.rb +1 -0
  72. data/lib/jekyll_picture_tag/instructions/arg_splitter.rb +69 -0
  73. data/lib/jekyll_picture_tag/instructions/configuration.rb +1 -1
  74. data/lib/jekyll_picture_tag/instructions/preset.rb +40 -15
  75. data/lib/jekyll_picture_tag/instructions/set.rb +23 -9
  76. data/lib/jekyll_picture_tag/instructions/tag_parser.rb +59 -69
  77. data/lib/jekyll_picture_tag/output_formats/basic.rb +34 -15
  78. data/lib/jekyll_picture_tag/output_formats/img.rb +11 -0
  79. data/lib/jekyll_picture_tag/output_formats/picture.rb +22 -0
  80. data/lib/jekyll_picture_tag/router.rb +9 -0
  81. data/lib/jekyll_picture_tag/source_image.rb +60 -44
  82. data/lib/jekyll_picture_tag/srcsets/basic.rb +29 -7
  83. data/lib/jekyll_picture_tag/utils.rb +18 -0
  84. data/lib/jekyll_picture_tag/version.rb +1 -1
  85. data/readme.md +40 -16
  86. metadata +67 -20
  87. data/docs/_layouts/directory.html +0 -32
  88. data/docs/assets/style.css +0 -31
  89. data/docs/contributing.md +0 -75
  90. data/docs/example_presets.md +0 -116
  91. data/docs/global_configuration.md +0 -173
  92. data/docs/installation.md +0 -30
  93. data/docs/notes.md +0 -91
  94. data/docs/output.md +0 -63
  95. data/docs/presets.md +0 -309
  96. data/docs/usage.md +0 -113
@@ -1,30 +0,0 @@
1
- ---
2
- ---
3
- # Installation
4
-
5
- * Add `jekyll_picture_tag` to your Gemfile in the `:jekyll_plugins` group:
6
-
7
- ```ruby
8
- group :jekyll_plugins do
9
- gem 'jekyll_picture_tag'
10
- end
11
- ```
12
-
13
- * Run `$ bundle install`
14
-
15
- * See if you have ImageMagick with `$ convert --version`. You should see something like this:
16
-
17
- ```
18
- ~ $ convert --version
19
- Version: ImageMagick 7.0.8-14 Q16 x86_64 2018-10-31 https://imagemagick.org
20
- Copyright: © 1999-2018 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php
21
- Features: Cipher DPC HDRI OpenMP Delegates (built-in): bzlib fontconfig freetype jng jp2 jpeg lcms
22
- lzma pangocairo png tiff webp xml zlib
23
- ```
24
- If you get a 'command not found' error, you'll need to install it. Most package managers know about
25
- ImageMagick, otherwise it can be found [here](https://imagemagick.org/script/download.php).
26
-
27
- * **Note webp under delegates.** This is required if you want to generate webp files. Any image format
28
- you want to handle will require an appropriate delegate; You may have to install additional packages
29
- to accomplish this.
30
-
@@ -1,91 +0,0 @@
1
- ---
2
- ---
3
- # Notes and FAQ
4
-
5
- * #### Github Pages?
6
-
7
- Github Pages only allows a very short whitelist of plugins, which sadly does not include JPT. You
8
- can either run it locally, then commit and push the generated files (rather than the source
9
- files), or just host it some other way. I recommend Netlify.
10
-
11
- * #### HTML attributes
12
-
13
- Jekyll Picture Tag has comprehensive attribute support for all generated HTML. You can add
14
- attributes both through the [liquid tag]({{ site.baseurl }}/usage), and the [preset]({{
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
26
- provider makes those images available during the build process. Netlify, for example, does not.
27
- You won't find this out until you have gone through the entire migration process and try to deploy
28
- for the first time.
29
-
30
-
31
- * #### Extra {::nomarkdown} tags or mangled HTML?
32
-
33
- **TLDR up front:** There's a bug involving `<picture>` tags wrapped in `<a>` tags which is not in my
34
- power to fix.
35
-
36
- * If you're getting extra `{::nomarkdown}` tags floating around your images, add `nomarkdown:
37
- false` to either the relevant preset or under `picture` in `_config.yml`.
38
-
39
- * If you're getting mangled HTML when trying to wrap images with anchor tags, add `nomarkdown:
40
- true` to the preset.
41
-
42
- **What's going on here:**
43
-
44
- Kramdown is Jekyll's default markdown parser. Kramdown gets grumpy when you give it a block level
45
- element (such as a `<picture>`) surrounded by a span level element (such as an `<a>`), and horribly
46
- mangles it. The fix for this is to tell Kramdown to chill with a `{::nomarkdown}..{:/nomarkdown}`
47
- wrapper.
48
-
49
- Jekyll Picture Tag can be called from many different places: a markdown file, an HTML file, an HTML
50
- layout for a markdown file, and an HTML include, to name a few. JPT tries its best to determine
51
- whether its output will be parsed by Kramdown or not, but Jekyll itself doesn't make this
52
- particularly easy which results in some false positives. (The one I'm most aware of is when a
53
- markdown file uses an HTML layout which includes a picture tag.)
54
-
55
- Unfortunately, I don't see an easy way to fix this. We've gotten this far mostly by trial and error.
56
- I'll continue to work on improving the autodetection, but you can override this behavior explicitly.
57
-
58
- **The fix:**
59
-
60
- By default, JPT will add a `{::nomarkdown}` tag if all of the following are true:
61
- * It thinks it's called from a markdown page
62
- * The image will be wrapped in an anchor tag (i.e. `link_source_image:` or a `--link` parameter)
63
- * This behavior hasn't been explicitly disabled.
64
-
65
- You can disable nomarkdown tags globally by setting `nomarkdown: false` under the `picture:` key in
66
- `_config.yml`.
67
-
68
- You can enable or disable markdown tags per preset by adding `nomarkdown: true|false` to them.
69
- **This setting overrides everything else, both JPT autodetection and the global setting.**
70
-
71
- * ### Managing Generated Images
72
-
73
- Jekyll Picture Tag creates resized versions of your images when you build the site. It uses a
74
- smart caching system to speed up site compilation, and re-uses images as much as possible.
75
- Filenames take the following format:
76
-
77
- `(original name without extension)-(width)-(source hash).(filetype)`
78
-
79
- Source hash is the first 5 characters of an md5 checksum of the source image.
80
-
81
- Try to use a base image that is larger than the largest resized image you need. Jekyll Picture Tag
82
- will warn you if a base image is too small, and won't upscale images.
83
-
84
- By specifying a `source` directory that is ignored by Jekyll you can prevent huge base images from
85
- being copied to the compiled site. For example, `source: assets/images/_fullsize` and `output:
86
- generated` will result in a compiled site that contains resized images but not the originals. Note
87
- that this will break source image linking, if you wish to enable it. (Can't link to images that
88
- aren't public!)
89
-
90
- The `output` directory is never deleted by Jekyll. You may want to empty it once in awhile, to
91
- clear out unused images.
@@ -1,63 +0,0 @@
1
- ---
2
- ---
3
-
4
- # Output Formats
5
-
6
- This is a listing of the various text arrangements that JPT can give you. Select one by setting
7
- `markup:` in the relevant [markup preset]({{ site.baseurl }}/presets).
8
-
9
- Example:
10
-
11
- ```yml
12
- # /_data/picture.yml
13
-
14
- markup_presets:
15
- my_preset:
16
- markup: data_auto
17
- ```
18
-
19
- ## Standard HTML:
20
-
21
- - **`picture`:** `<picture>` element surrounding a `<source>` tag for each required srcset, and a
22
- fallback `<img>`.
23
-
24
- - **`img`:** output a single `<img>` tag with a `srcset` entry.
25
-
26
- - **`auto`:** Supply an img tag when you have only one srcset, otherwise supply a picture tag.
27
-
28
- ## Javascript Friendly:
29
-
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).
33
-
34
- #### Special Options
35
-
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.)
56
-
57
- ## Fragments:
58
-
59
- - **`direct_url`**: Generates an image and returns only its url. Uses `fallback_` properties (width
60
- and format).
61
-
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.
@@ -1,309 +0,0 @@
1
- ---
2
- ---
3
-
4
- # Writing Presets
5
-
6
- Presets are named collections of settings that determine basically everything about JPT's output.
7
- They are stored in `_data/picture.yml`, to avoid cluttering `_config.yml`. You will have to create
8
- this file, and probably the `_data/` directory as well.
9
-
10
- Here's an [example data file]({{ site.baseurl }}/example_presets).
11
-
12
- Any settings which are specific to particular output formats are documented on the [output
13
- formats]({{site.baseurl}}/output) page.
14
-
15
- ## Required Knowledge
16
-
17
- If you don't know the difference between resolution switching and art direction, stop now and read
18
- the [MDN Responsive Images
19
- guide](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images)
20
- in detail. Ideally, play around with a basic HTML file, a few test images, and a few different
21
- browser widths until you understand it.
22
-
23
- ## Media Presets
24
-
25
- *Format:*
26
-
27
- ```yml
28
- media_presets:
29
- (name): (css media query)
30
- (name): (css media query)
31
- (...)
32
-
33
- ```
34
-
35
- *Example:*
36
-
37
- ```yml
38
- media_presets:
39
- desktop: 'min-width: 1200px'
40
- ```
41
-
42
- These are named media queries for use in a few different places: specifying alternate source images
43
- in your liquid tag, building the 'sizes' attribute within your presets, and in a few configuration
44
- settings. Quotes are recommended around the media queries, because yml gets confused by colons.
45
-
46
- ## Markup Presets
47
-
48
- *Format:*
49
-
50
- ```yml
51
- markup_presets:
52
- (name):
53
- (option): (setting)
54
- (option): (setting)
55
- (...)
56
- (...)
57
- ```
58
-
59
- *Example:*
60
-
61
- ```yml
62
- markup_presets:
63
- default:
64
- formats: [webp, original]
65
- widths: [200, 400, 800, 1600]
66
- link_source: true
67
- lazy:
68
- markup: data_auto
69
- widths: [200, 400, 800, 1600]
70
- link_source: true
71
- noscript: true
72
- ```
73
-
74
- Each entry is a pre-defined collection of settings to build a given chunk of text (usually HTML) and
75
- its respective images. You can select one as the first argument given to the tag:
76
-
77
- {% raw %}
78
- `{% picture my-preset image.jpg %}`
79
- {% endraw %}
80
-
81
- The `default` preset will be used if none is specified. A preset name can't contain a `.` (period).
82
-
83
- #### A Note on srcsets
84
-
85
- For images that are different sizes on different screens (most images), use a width-based srcset
86
- (which is the default). Specify a `widths` setting (or don't, for the default set), and optionally
87
- the `sizes` and `size` settings.
88
-
89
- Use a multiplier-based srcset when the image will always be the same size, regardless of screen
90
- width (thumbnails and icons). To use a multiplier-based srcset, set `pixel_ratios` and `base_width`.
91
-
92
- ### Settings reference
93
-
94
- * **Markup format**
95
-
96
- *Format:* `markup: (setting)`
97
-
98
- *Default*: `auto`
99
-
100
- Defines what format the generated text will take. They are documented [here]({{ site.baseurl }}/output).
101
-
102
-
103
- * **Image Formats**
104
-
105
- *Format:* `format: [format1, format2, (...)]`
106
-
107
- *Example:* `format: [webp, original]`
108
-
109
- *Default*: `original`
110
-
111
- Array (yml sequence) of the image formats you'd like to generate, in decreasing order of
112
- preference. Browsers will render the first format they find and understand, so **If you put jpg
113
- before webp, your webp images will never be used**. `original` does what you'd expect. To supply
114
- webp, you must have an imagemagick webp delegate installed. (Most package managers just name it
115
- 'webp')
116
-
117
- *Supported formats are anything which imagemagick supports, and has an installed delegate. See a
118
- list by running `$ convert --version`*
119
-
120
- * **Widths**
121
-
122
- *Format:* `widths: [integer, integer, (...)]`
123
-
124
- *Example:* `widths: [600, 800, 1200]`
125
-
126
- *Default*: `[400, 600, 800, 1000]`
127
-
128
- Array of image widths to generate, in pixels. For use when you want a width-based srcset
129
- (`srcset="img.jpg 800w, img2.jpg 1600w"`).
130
-
131
- * **Media_widths**
132
-
133
- *Format:*
134
-
135
- ```yml
136
- media_widths:
137
- (media preset name): [integer, integer, (...)]
138
- ```
139
-
140
- *Example:*
141
-
142
- ```yml
143
- media_widths:
144
- mobile: [400, 600, 800]
145
- ```
146
-
147
- *Default:* Widths setting
148
-
149
- If you are using art direction, there is no sense in generating desktop-size files for your mobile
150
- image. You can specify sets of widths to associate with given media queries. If not specified,
151
- will use `widths` setting.
152
-
153
- * **Sizes**
154
-
155
- *Format:*
156
-
157
- ```yml
158
- sizes:
159
- (media preset): (CSS dimension)
160
- (...)
161
- ```
162
-
163
- *Example:*
164
-
165
- ```yml
166
- sizes:
167
- mobile: 80vw
168
- tablet: 60vw
169
- desktop: 900px
170
- ```
171
-
172
- Conditional sizes, used to construct the `sizes=` HTML attribute telling the browser how wide your
173
- image will be (on the screen) when a given media query is true. CSS dimensions can be given in
174
- `px`, `em`, or `vw`. To be used along with a width-based srcset.
175
-
176
- Provide these in order of most restrictive to least restrictive. The browser will choose the
177
- first one with an applicable media query.
178
-
179
- You don't have to provide a sizes attribute at all. If you don't, the browser will assume the
180
- image is 100% the width of the viewport.
181
-
182
- * **Size**
183
-
184
- *Format:* `size: (CSS Dimension)`
185
-
186
- *Example:* `size: 80vw`
187
-
188
- Unconditional `sizes` setting, to be supplied either alone or after all conditional sizes.
189
-
190
- * **Pixel Ratios**
191
-
192
- *Format:* `pixel_ratios: [number, number, number (...)]`
193
-
194
- *Example:* `pixel_ratios: [1, 1.5, 2]`
195
-
196
- Array of images to construct, given in multiples of the base width. If you set this, you must also
197
- give a `base_width`.
198
-
199
- Set this when you want a multiplier based srcset (example: `srcset="img.jpg 1x, img2.jpg 2x"`).
200
-
201
- * **Base Width**
202
-
203
- *Format:* `base_width: integer`
204
-
205
- *Example:* `base_width: 100`
206
-
207
- When using pixel ratios, you must supply a base width. This sets how wide the 1x image should be.
208
-
209
- * **Quality**
210
-
211
- *Format:* `quality: 0 <= integer <= 100`
212
-
213
- *Example:* `quality: 80`
214
-
215
- *Default:* `75`
216
-
217
- This allows you to specify an image compression level for all image formats (where it makes sense,
218
- anyway). The next option allows you to set them per format.
219
-
220
- * **Format Quality**
221
-
222
- *Format:*
223
-
224
- ```yml
225
- format_quality:
226
- (format): 0 <= integer <= 100
227
- (...)
228
- ```
229
-
230
- *Example:*
231
-
232
- ```
233
- format_quality:
234
- jpg: 75
235
- png: 65
236
- webp: 55
237
- ```
238
-
239
- *Default:* quality setting (above)
240
-
241
- This allows you to specify quality settings for various image formats, allowing you to take
242
- advantage of webp's better compression algorithm without trashing your jpg images (for example).
243
- If you don't give a setting for a particular format it'll fall back to the `quality` setting
244
- above, and if you don't set *that* it'll default to 75.
245
-
246
- * **HTML Attributes**
247
-
248
- *Format:*
249
-
250
- ```yml
251
- attributes:
252
- (element): '(attributes)'
253
- (...)
254
- ```
255
-
256
- *Example:*
257
-
258
- ```yml
259
- attributes:
260
- img: 'class="soopercool" data-awesomeness="11"'
261
- picture: 'class="even-cooler"'
262
- ```
263
-
264
- HTML attributes you would like to add. The same arguments are available here as in the liquid
265
- tag: HTML element names, `alt:`, `link:`, and `parent:`. Unescaped double quotes cause problems
266
- with yml, so it's recommended to surround them with single quotes.
267
-
268
- * **Fallback Width**
269
-
270
- *Format:* `fallback_width: (integer)`
271
-
272
- *Example:* `fallback_width: 800`
273
-
274
- *Default*: `800`
275
-
276
- Width of the fallback image.
277
-
278
- * **Fallback Format**
279
-
280
- *Format:* `fallback_format: (format)`
281
-
282
- *Example:* `fallback_format: jpg`
283
-
284
- *Default*: `original`
285
-
286
- Format of the fallback image
287
-
288
- * **Source Image Link**
289
-
290
- *Format:* `link_source: (true|false)`
291
-
292
- *Example:* `link_source: true`
293
-
294
- *Default:* `false`
295
-
296
- Surround image with a link to the original source file. Your source image directory must be
297
- published as part of the compiled site. If you run into weird issues with the output, see
298
- the [notes]({{ site.baseurl }}/notes).
299
-
300
- * **Nomarkdown override**
301
-
302
- *Format:* `nomarkdown: (true|false)`
303
-
304
- *Example:* `nomarkdown: false`
305
-
306
- *Default:* `nil`
307
-
308
- Hard setting for `{::nomarkdown}` tags, overrides both autodetection and the global setting in
309
- `_config.yml`. See the [notes]({{ site.baseurl }}/notes) for a detailed explanation.