jekyll_picture_tag 1.10.2 → 2.0.0pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.envrc +4 -0
  3. data/.github/workflows/code-checks.yml +33 -0
  4. data/.gitignore +3 -0
  5. data/.rubocop.yml +32 -0
  6. data/.ruby-version +1 -1
  7. data/docs/.envrc +2 -0
  8. data/docs/Gemfile +4 -2
  9. data/docs/Gemfile.lock +14 -12
  10. data/docs/_config.yml +6 -10
  11. data/docs/devs/contributing/code.md +54 -0
  12. data/docs/devs/contributing/docs.md +31 -0
  13. data/docs/devs/contributing/index.md +15 -0
  14. data/docs/devs/contributing/setup.md +33 -0
  15. data/docs/devs/contributing/testing.md +23 -0
  16. data/docs/devs/index.md +7 -0
  17. data/docs/devs/releases.md +113 -0
  18. data/docs/index.md +62 -31
  19. data/docs/logo.png +0 -0
  20. data/docs/logo.svg +880 -0
  21. data/docs/users/configuration/directories.md +34 -0
  22. data/docs/users/configuration/disable.md +24 -0
  23. data/docs/users/configuration/fast_build.md +28 -0
  24. data/docs/users/configuration/ignore_missing.md +23 -0
  25. data/docs/users/configuration/index.md +29 -0
  26. data/docs/users/configuration/kramdown_fix.md +20 -0
  27. data/docs/users/configuration/suppress_warnings.md +16 -0
  28. data/docs/users/configuration/urls.md +69 -0
  29. data/docs/users/getting_started.md +55 -0
  30. data/docs/users/index.md +7 -0
  31. data/docs/users/installation.md +31 -0
  32. data/docs/users/liquid_tag/argument_reference/alternate_images.md +18 -0
  33. data/docs/users/liquid_tag/argument_reference/attributes.md +42 -0
  34. data/docs/users/liquid_tag/argument_reference/base_image.md +12 -0
  35. data/docs/users/liquid_tag/argument_reference/crop.md +33 -0
  36. data/docs/users/liquid_tag/argument_reference/link.md +16 -0
  37. data/docs/users/liquid_tag/argument_reference/preset.md +17 -0
  38. data/docs/users/liquid_tag/argument_reference/readme.md +9 -0
  39. data/docs/users/liquid_tag/examples.md +81 -0
  40. data/docs/users/liquid_tag/index.md +31 -0
  41. data/docs/users/notes/git_lfs.md +7 -0
  42. data/docs/users/notes/github_pages.md +5 -0
  43. data/docs/users/notes/html_attributes.md +5 -0
  44. data/docs/users/notes/index.md +6 -0
  45. data/docs/users/notes/kramdown_bug.md +41 -0
  46. data/docs/users/notes/managing_images.md +21 -0
  47. data/docs/{migration.md → users/notes/migration_1.md} +1 -1
  48. data/docs/users/notes/migration_2.md +99 -0
  49. data/docs/users/presets/cropping.md +60 -0
  50. data/docs/users/presets/default.md +32 -0
  51. data/docs/users/presets/examples.md +111 -0
  52. data/docs/users/presets/fallback_image.md +28 -0
  53. data/docs/users/presets/html_attributes.md +26 -0
  54. data/docs/users/presets/image_formats.md +21 -0
  55. data/docs/users/presets/image_quality.md +120 -0
  56. data/docs/users/presets/index.md +137 -0
  57. data/docs/users/presets/link_source.md +16 -0
  58. data/docs/users/presets/markup_formats/fragments.md +48 -0
  59. data/docs/users/presets/markup_formats/javascript_friendly.md +57 -0
  60. data/docs/users/presets/markup_formats/readme.md +43 -0
  61. data/docs/users/presets/markup_formats/standard_html.md +25 -0
  62. data/docs/users/presets/media_queries.md +36 -0
  63. data/docs/users/presets/nomarkdown_override.md +17 -0
  64. data/docs/users/presets/pixel_ratio_srcsets.md +32 -0
  65. data/docs/users/presets/quality_width_graph.png +0 -0
  66. data/docs/users/presets/width_height_attributes.md +34 -0
  67. data/docs/users/presets/width_srcsets.md +123 -0
  68. data/docs/users/tutorial.md +97 -0
  69. data/jekyll_picture_tag.gemspec +38 -24
  70. data/lib/jekyll_picture_tag.rb +11 -9
  71. data/lib/jekyll_picture_tag/cache.rb +64 -0
  72. data/lib/jekyll_picture_tag/defaults/global.rb +18 -0
  73. data/lib/jekyll_picture_tag/defaults/presets.rb +57 -0
  74. data/lib/jekyll_picture_tag/images.rb +4 -0
  75. data/lib/jekyll_picture_tag/images/generated_image.rb +92 -0
  76. data/lib/jekyll_picture_tag/images/image_file.rb +90 -0
  77. data/lib/jekyll_picture_tag/{img_uri.rb → images/img_uri.rb} +4 -10
  78. data/lib/jekyll_picture_tag/images/source_image.rb +138 -0
  79. data/lib/jekyll_picture_tag/instructions.rb +70 -6
  80. data/lib/jekyll_picture_tag/instructions/children/config.rb +128 -0
  81. data/lib/jekyll_picture_tag/instructions/children/context.rb +24 -0
  82. data/lib/jekyll_picture_tag/instructions/children/params.rb +90 -0
  83. data/lib/jekyll_picture_tag/instructions/children/parsers.rb +41 -0
  84. data/lib/jekyll_picture_tag/instructions/children/preset.rb +182 -0
  85. data/lib/jekyll_picture_tag/instructions/parents/conditional_instruction.rb +69 -0
  86. data/lib/jekyll_picture_tag/instructions/parents/env_instruction.rb +29 -0
  87. data/lib/jekyll_picture_tag/output_formats/basic.rb +11 -21
  88. data/lib/jekyll_picture_tag/output_formats/img.rb +11 -0
  89. data/lib/jekyll_picture_tag/output_formats/picture.rb +22 -0
  90. data/lib/jekyll_picture_tag/parsers.rb +5 -0
  91. data/lib/jekyll_picture_tag/{instructions → parsers}/arg_splitter.rb +4 -3
  92. data/lib/jekyll_picture_tag/parsers/configuration.rb +28 -0
  93. data/lib/jekyll_picture_tag/{instructions → parsers}/html_attributes.rb +1 -1
  94. data/lib/jekyll_picture_tag/parsers/preset.rb +43 -0
  95. data/lib/jekyll_picture_tag/{instructions → parsers}/tag_parser.rb +15 -12
  96. data/lib/jekyll_picture_tag/router.rb +35 -92
  97. data/lib/jekyll_picture_tag/srcsets/basic.rb +11 -8
  98. data/lib/jekyll_picture_tag/utils.rb +24 -20
  99. data/lib/jekyll_picture_tag/version.rb +1 -1
  100. data/readme.md +15 -12
  101. metadata +206 -95
  102. data/.travis.yml +0 -8
  103. data/Dockerfile +0 -9
  104. data/docs/_layouts/directory.html +0 -32
  105. data/docs/assets/style.css +0 -31
  106. data/docs/contributing.md +0 -109
  107. data/docs/example_presets.md +0 -116
  108. data/docs/global_configuration.md +0 -173
  109. data/docs/installation.md +0 -45
  110. data/docs/notes.md +0 -91
  111. data/docs/output.md +0 -63
  112. data/docs/presets.md +0 -361
  113. data/docs/releases.md +0 -65
  114. data/docs/usage.md +0 -143
  115. data/jekyll-picture-tag.gemspec +0 -52
  116. data/lib/jekyll-picture-tag.rb +0 -25
  117. data/lib/jekyll_picture_tag/defaults/global.yml +0 -11
  118. data/lib/jekyll_picture_tag/defaults/presets.yml +0 -10
  119. data/lib/jekyll_picture_tag/generated_image.rb +0 -161
  120. data/lib/jekyll_picture_tag/instructions/configuration.rb +0 -121
  121. data/lib/jekyll_picture_tag/instructions/preset.rb +0 -102
  122. data/lib/jekyll_picture_tag/instructions/set.rb +0 -71
  123. data/lib/jekyll_picture_tag/source_image.rb +0 -87
@@ -0,0 +1,16 @@
1
+ ---
2
+ sort: 11
3
+ ---
4
+
5
+ # Source Image Link
6
+
7
+ _Format:_ `link_source: (true|false)`
8
+
9
+ _Example:_ `link_source: true`
10
+
11
+ _Default:_ `false`
12
+
13
+ Surround image with a link to the original source file. Your source image
14
+ directory must be published as part of the compiled site. If you run into weird
15
+ issues with the output, see the [notes]({{ site.baseurl }}/notes).
16
+
@@ -0,0 +1,48 @@
1
+ ---
2
+ sort: 3
3
+ ---
4
+
5
+ # Fragments
6
+
7
+ The following are not complete markup; they're building blocks that you can use
8
+ to make things outside the scope of JPT.
9
+
10
+ - `direct_url` Generates an image and returns only its url. Uses
11
+ `fallback_width` and `fallback_format`.
12
+
13
+ ```yml
14
+ # _data/picture.yml
15
+
16
+ markup_presets:
17
+ direct:
18
+ markup: direct_url
19
+ fallback_width: 800
20
+ fallback_format: webp
21
+ ```
22
+
23
+ ```
24
+ {% raw %}
25
+ {% picture direct myimage.jpg %} --> /generated/myimage-800-abcd12345.webp
26
+ {% endraw %}
27
+ ```
28
+
29
+ - `naked_srcset`: Builds a srcset and nothing else (not even the surrounding quotes). Note that the
30
+ (image) `format` setting must still be an array, even if you only give it one
31
+ value. (This is on the list of things to improve.)
32
+
33
+ ```yml
34
+ # _data/picture.yml
35
+
36
+ markup_presets:
37
+ only_srcset:
38
+ markup: naked_srcset
39
+ widths: [800, 1200, 1600]
40
+ format: [webp]
41
+ ```
42
+
43
+ ```
44
+ {% raw %}
45
+ {% picture only_srcset myimage.jpg %} -->
46
+ /generated/myimage-800-abcd12345.webp 800w, /generated/myimage-1200-abcd12345.webp 1200w, (...)
47
+ {% endraw %}
48
+ ```
@@ -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: 2
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: 12
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: 5
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
+
@@ -0,0 +1,34 @@
1
+ ---
2
+ sort: 8
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,123 @@
1
+ ---
2
+ sort: 4
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
+ You should use it when the size of an image depends on the size of the screen used to show it, which
14
+ generally means anything bigger than about 300 pixels. It's the default; to use it specify a
15
+ `widths` setting (or don't, for the default set), and optionally the `sizes` and `size` settings.
16
+
17
+ ## A word on sizes
18
+
19
+ The `sizes` attribute is both important, and impossible to offer good defaults for. Web browsers parse
20
+ web pages line-by-line. When they run into an external asset (such as an image) they must download,
21
+ they start that process immediately without waiting to draw the page. This means that at the point
22
+ in time when the browser must decide which image to download, it has no clue how large that image
23
+ will be on the page. The sizes attribute is how we tell it.
24
+
25
+ It doesn't have to be pixel-perfect, just close enough for the browser to make a good choice. You
26
+ can't use % (percentage width of the parent container) for the same reason we have to do this at
27
+ all. If you do not provide it, the web browser will assume the image is 100vw (100% the width of
28
+ the viewport.)
29
+
30
+ ## How to create a sizes attribute
31
+
32
+ First, Load the page and image as they will appear in the final site. (Basically write the rest of
33
+ the preset.)
34
+
35
+ Next, using either dev tools or by manipulating the browser window itself, determine how large the
36
+ image will be for all reasonable screen sizes. Organize this information into CSS measurements
37
+ (using `vw`, `vh`, `px`, `em`, or a calculation based on those units) associated with your
38
+ named CSS media queries, and enter them into the relevant preset. **Order matters**; enter these
39
+ from most to least restrictive. The browser will ignore everything after the first media query it
40
+ finds that is true.
41
+
42
+ **Example:** on my particular site, for screens 900px or smaller, inline images are the width of the
43
+ viewport minus 9px of padding on either side. For screens 901px or larger, they are a constant 862px
44
+ wide. The relevant lines in my config file look like this:
45
+
46
+ ```yml
47
+ media_queries:
48
+ full_width: 'min-width: 901px'
49
+ # (...)
50
+
51
+ presets:
52
+ default:
53
+ # (...)
54
+ sizes:
55
+ full_width: 862px
56
+ size: calc(100vw - 18px)
57
+ ```
58
+
59
+ ## Settings Reference
60
+
61
+ ### Widths
62
+
63
+ _Format:_ `widths: [integer, integer, (...)]`
64
+
65
+ _Example:_ `widths: [600, 800, 1200]`
66
+
67
+ _Default_: `[400, 600, 800, 1000]`
68
+
69
+ Array of image widths to generate, in pixels.
70
+
71
+ ### Media Widths
72
+
73
+ _Format:_
74
+
75
+ ```yml
76
+ media_widths:
77
+ (media_query name): [integer, integer, (...)]
78
+ ```
79
+
80
+ _Example:_
81
+
82
+ ```yml
83
+ media_widths:
84
+ mobile: [400, 600, 800]
85
+ ```
86
+
87
+ _Default:_ `widths` setting
88
+
89
+ If you are using art direction, there is no sense in generating desktop-size files for your mobile
90
+ image. Similarly, there's no sense in generating 300px wide versions of your ultrawide crop. You can
91
+ specify sets of widths to associate with given media queries.
92
+
93
+ ### Sizes
94
+
95
+ _Format:_
96
+
97
+ ```yml
98
+ sizes:
99
+ (media preset): (CSS dimension)
100
+ (...)
101
+ ```
102
+
103
+ _Example:_
104
+
105
+ ```yml
106
+ sizes:
107
+ mobile: 80vw
108
+ tablet: 60vw
109
+ desktop: 900px
110
+ ```
111
+
112
+ Conditional sizes, used to construct the `sizes=` HTML attribute telling the browser how wide your
113
+ image will be (on the screen) when a given media query is true. CSS dimensions can be given in `px`,
114
+ `em`, or `vw`. Provide these in order of most restrictive to least restrictive. The browser will
115
+ choose the first one with an applicable media query.
116
+
117
+ ### Size
118
+
119
+ _Format:_ `size: (CSS Dimension)`
120
+
121
+ _Example:_ `size: 80vw`
122
+
123
+ Unconditional `sizes` setting, to be supplied either alone or after all conditional sizes.