jekyll_picture_tag 1.11.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.envrc +4 -0
- data/.github/workflows/code-checks.yml +33 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +31 -3
- data/.ruby-version +1 -1
- data/docs/.envrc +2 -0
- data/docs/Gemfile +4 -2
- data/docs/Gemfile.lock +14 -12
- data/docs/_config.yml +6 -10
- data/docs/devs/contributing/code.md +54 -0
- data/docs/devs/contributing/docs.md +31 -0
- data/docs/devs/contributing/index.md +15 -0
- data/docs/devs/contributing/setup.md +33 -0
- data/docs/devs/contributing/testing.md +23 -0
- data/docs/devs/index.md +7 -0
- data/docs/devs/releases.md +118 -0
- data/docs/index.md +67 -31
- data/docs/logo.png +0 -0
- data/docs/logo.svg +880 -0
- data/docs/users/configuration/directories.md +34 -0
- data/docs/users/configuration/disable.md +24 -0
- data/docs/users/configuration/fast_build.md +28 -0
- data/docs/users/configuration/ignore_missing.md +23 -0
- data/docs/users/configuration/index.md +29 -0
- data/docs/users/configuration/kramdown_fix.md +20 -0
- data/docs/users/configuration/suppress_warnings.md +16 -0
- data/docs/users/configuration/urls.md +69 -0
- data/docs/users/getting_started.md +55 -0
- data/docs/users/index.md +7 -0
- data/docs/users/installation.md +32 -0
- data/docs/users/liquid_tag/argument_reference/alternate_images.md +18 -0
- data/docs/users/liquid_tag/argument_reference/attributes.md +42 -0
- data/docs/users/liquid_tag/argument_reference/base_image.md +12 -0
- data/docs/users/liquid_tag/argument_reference/crop.md +33 -0
- data/docs/users/liquid_tag/argument_reference/link.md +16 -0
- data/docs/users/liquid_tag/argument_reference/preset.md +17 -0
- data/docs/users/liquid_tag/argument_reference/readme.md +9 -0
- data/docs/users/liquid_tag/examples.md +81 -0
- data/docs/users/liquid_tag/index.md +31 -0
- data/docs/users/notes/git_lfs.md +7 -0
- data/docs/users/notes/github_pages.md +5 -0
- data/docs/users/notes/html_attributes.md +5 -0
- data/docs/users/notes/index.md +6 -0
- data/docs/users/notes/kramdown_bug.md +41 -0
- data/docs/users/notes/managing_images.md +21 -0
- data/docs/{migration.md → users/notes/migration_1.md} +1 -1
- data/docs/users/notes/migration_2.md +99 -0
- data/docs/users/presets/cropping.md +60 -0
- data/docs/users/presets/default.md +32 -0
- data/docs/users/presets/examples.md +111 -0
- data/docs/users/presets/fallback_image.md +28 -0
- data/docs/users/presets/html_attributes.md +26 -0
- data/docs/users/presets/image_formats.md +21 -0
- data/docs/users/presets/image_quality.md +120 -0
- data/docs/users/presets/index.md +75 -0
- data/docs/users/presets/link_source.md +16 -0
- data/docs/users/presets/markup_formats/fragments.md +48 -0
- data/docs/users/presets/markup_formats/javascript_friendly.md +57 -0
- data/docs/users/presets/markup_formats/readme.md +43 -0
- data/docs/users/presets/markup_formats/standard_html.md +25 -0
- data/docs/users/presets/media_queries.md +36 -0
- data/docs/users/presets/nomarkdown_override.md +17 -0
- data/docs/users/presets/pixel_ratio_srcsets.md +32 -0
- data/docs/users/presets/quality_width_graph.png +0 -0
- data/docs/users/presets/width_height_attributes.md +34 -0
- data/docs/users/presets/width_srcsets.md +123 -0
- data/docs/users/presets/writing_presets.md +65 -0
- data/docs/users/tutorial.md +97 -0
- data/jekyll_picture_tag.gemspec +38 -23
- data/lib/jekyll_picture_tag.rb +11 -10
- data/lib/jekyll_picture_tag/cache.rb +64 -3
- data/lib/jekyll_picture_tag/defaults/global.rb +18 -0
- data/lib/jekyll_picture_tag/defaults/presets.rb +57 -0
- data/lib/jekyll_picture_tag/images.rb +4 -0
- data/lib/jekyll_picture_tag/images/generated_image.rb +92 -0
- data/lib/jekyll_picture_tag/images/image_file.rb +90 -0
- data/lib/jekyll_picture_tag/{img_uri.rb → images/img_uri.rb} +3 -10
- data/lib/jekyll_picture_tag/{source_image.rb → images/source_image.rb} +44 -9
- data/lib/jekyll_picture_tag/instructions.rb +70 -6
- data/lib/jekyll_picture_tag/instructions/children/config.rb +128 -0
- data/lib/jekyll_picture_tag/instructions/children/context.rb +24 -0
- data/lib/jekyll_picture_tag/instructions/children/params.rb +90 -0
- data/lib/jekyll_picture_tag/instructions/children/parsers.rb +41 -0
- data/lib/jekyll_picture_tag/instructions/children/preset.rb +182 -0
- data/lib/jekyll_picture_tag/instructions/parents/conditional_instruction.rb +69 -0
- data/lib/jekyll_picture_tag/instructions/parents/env_instruction.rb +29 -0
- data/lib/jekyll_picture_tag/output_formats/basic.rb +5 -17
- data/lib/jekyll_picture_tag/parsers.rb +5 -0
- data/lib/jekyll_picture_tag/{instructions → parsers}/arg_splitter.rb +1 -1
- data/lib/jekyll_picture_tag/parsers/configuration.rb +28 -0
- data/lib/jekyll_picture_tag/{instructions → parsers}/html_attributes.rb +1 -1
- data/lib/jekyll_picture_tag/parsers/preset.rb +43 -0
- data/lib/jekyll_picture_tag/{instructions → parsers}/tag_parser.rb +15 -12
- data/lib/jekyll_picture_tag/router.rb +35 -93
- data/lib/jekyll_picture_tag/srcsets/basic.rb +4 -10
- data/lib/jekyll_picture_tag/utils.rb +24 -20
- data/lib/jekyll_picture_tag/version.rb +1 -1
- data/readme.md +15 -13
- metadata +215 -93
- data/.travis.yml +0 -8
- data/Dockerfile +0 -9
- data/docs/_layouts/directory.html +0 -32
- data/docs/assets/style.css +0 -31
- data/docs/contributing.md +0 -109
- data/docs/example_presets.md +0 -116
- data/docs/global_configuration.md +0 -173
- data/docs/installation.md +0 -45
- data/docs/notes.md +0 -91
- data/docs/output.md +0 -63
- data/docs/presets.md +0 -391
- data/docs/releases.md +0 -70
- data/docs/usage.md +0 -157
- data/jekyll-picture-tag.gemspec +0 -52
- data/lib/jekyll-picture-tag.rb +0 -25
- data/lib/jekyll_picture_tag/cache/base.rb +0 -59
- data/lib/jekyll_picture_tag/cache/generated.rb +0 -20
- data/lib/jekyll_picture_tag/cache/source.rb +0 -19
- data/lib/jekyll_picture_tag/defaults/global.yml +0 -11
- data/lib/jekyll_picture_tag/defaults/presets.yml +0 -11
- data/lib/jekyll_picture_tag/generated_image.rb +0 -140
- data/lib/jekyll_picture_tag/instructions/configuration.rb +0 -121
- data/lib/jekyll_picture_tag/instructions/preset.rb +0 -103
- data/lib/jekyll_picture_tag/instructions/set.rb +0 -71
@@ -0,0 +1,111 @@
|
|
1
|
+
---
|
2
|
+
sort: 2
|
3
|
+
---
|
4
|
+
# Examples
|
5
|
+
|
6
|
+
The following example media queries & presets (except for `default`) are built-in with a `jpt-`
|
7
|
+
prefix. For example, the `desktop` media query below can be used with `jpt-desktop`, and the `webp`
|
8
|
+
preset below can be used with `jpt-webp`.
|
9
|
+
|
10
|
+
```yaml
|
11
|
+
# _data/picture.yml
|
12
|
+
|
13
|
+
# These are used in several places. You likely want to enter whatever CSS media queries your site
|
14
|
+
# uses here.
|
15
|
+
media_queries:
|
16
|
+
mobile: 'max-width: 480px'
|
17
|
+
tablet: 'max-width: 768'
|
18
|
+
laptop: 'max-width: 1024px'
|
19
|
+
desktop: 'max-width: 1200'
|
20
|
+
wide: 'min-width: 1201'
|
21
|
+
|
22
|
+
presets:
|
23
|
+
# This entry is purely an example. It is not the default JPT preset, nor is it available as a
|
24
|
+
# built-in.
|
25
|
+
default:
|
26
|
+
formats: [webp, original] # Order matters!
|
27
|
+
widths: [200, 400, 800, 1200, 1600] # Image widths, in pixels.
|
28
|
+
|
29
|
+
# The sizes attribute is both important, and impossible to offer good defaults for. You need to
|
30
|
+
# learn about it. Short version: Web browsers parse web pages line-by-line. When they run into
|
31
|
+
# an external asset they must download, they start that process immediately, without waiting to
|
32
|
+
# finish rendering the page. This means that at the point in time when the browser must decide
|
33
|
+
# which image to download, it has no clue how large that image will be on the page. The sizes
|
34
|
+
# attribute is how we tell it.
|
35
|
+
#
|
36
|
+
# If you do not provide this, the web browser will assume the image is 100vw (100% the width of
|
37
|
+
# the viewport.)
|
38
|
+
#
|
39
|
+
# This doesn't have to be pixel-perfect, just close enough for the browser to make a good
|
40
|
+
# choice. Keys are media queries defined above, values are how large the image will be when
|
41
|
+
# that media query is true. You can't use % (percentage width of the parent container) for the
|
42
|
+
# same reason we have to do this at all.
|
43
|
+
sizes:
|
44
|
+
mobile: calc(100vw - 16px)
|
45
|
+
tablet: 80vw
|
46
|
+
|
47
|
+
# Size is unconditional; provided either after all conditional sizes (above) or alone. If you
|
48
|
+
# only have a 'size' (no 'sizes'), and it's a constant (px, em, or rem), you should use a
|
49
|
+
# pixel-ratio srcset.
|
50
|
+
size: 800px
|
51
|
+
|
52
|
+
link_source: true # wrap images in a link to the original source image.
|
53
|
+
dimension_attributes: true # Page reflow begone!
|
54
|
+
|
55
|
+
# You can add any HTML attribute you like, to any HTML element which JPT creates:
|
56
|
+
attributes:
|
57
|
+
# parent refers to the outermost tag; <picture> if it's present, otherwise the <img>.
|
58
|
+
parent: 'data-downloadable="true"'
|
59
|
+
picture: 'class="awesome" data-volume="11"'
|
60
|
+
img: 'class="some-other-class"'
|
61
|
+
a: 'class="image-link"'
|
62
|
+
|
63
|
+
# You can use this as jpt-webp. All following presets follow the same pattern.
|
64
|
+
webp:
|
65
|
+
formats: [webp, original]
|
66
|
+
|
67
|
+
# Avif is the new hotness coming down the pipe. Browser support is bad and they are slow to
|
68
|
+
# generate, but you get good file sizes even compared to webp of similar quality.
|
69
|
+
avif:
|
70
|
+
formats: [avif, webp, original]
|
71
|
+
|
72
|
+
# Your build times will suffer, but everyone is happy.
|
73
|
+
loaded:
|
74
|
+
formats: [avif, jp2, webp, original]
|
75
|
+
dimension_attributes: true
|
76
|
+
|
77
|
+
# This is an example of how you would create a 'multiplier' based srcset; useful when an image
|
78
|
+
# will always be the same size on all screens (icons, graphics, thumbnails, etc), but you'd like
|
79
|
+
# to supply higher resolution images to devices with higher pixel ratios.
|
80
|
+
thumbnail:
|
81
|
+
base_width: 250 # How wide the 1x image should be.
|
82
|
+
pixel_ratios: [1, 1.5, 2] # Which multipliers to target.
|
83
|
+
fallback_width: 250 # The default is 800, which is probably too big.
|
84
|
+
formats: [webp, original]
|
85
|
+
attributes:
|
86
|
+
picture: 'class="thumbnail"'
|
87
|
+
|
88
|
+
# Another pixel-ratio example.
|
89
|
+
avatar:
|
90
|
+
# Say your layout demands a square:
|
91
|
+
crop: 1:1
|
92
|
+
base_width: 100
|
93
|
+
pixel_ratios: [1, 1.5, 2]
|
94
|
+
fallback_width: 100,
|
95
|
+
|
96
|
+
# Here's an example of how you'd configure JPT to work with something like lazyload:
|
97
|
+
# https://github.com/verlok/lazyload
|
98
|
+
# Remember to add a sizes attribute, unless it's close to 100vw all the time.
|
99
|
+
lazy:
|
100
|
+
markup: data_auto
|
101
|
+
formats: [webp, original]
|
102
|
+
noscript: true # add a fallback image inside a <noscript> tag.
|
103
|
+
attributes:
|
104
|
+
parent: class="lazy"
|
105
|
+
|
106
|
+
# This is an example of how you'd get a single generated image, a URL, and nothing else.
|
107
|
+
direct:
|
108
|
+
markup: direct_url
|
109
|
+
fallback_format: webp
|
110
|
+
fallback_width: 600
|
111
|
+
```
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
sort: 11
|
3
|
+
---
|
4
|
+
|
5
|
+
# Fallback Image
|
6
|
+
|
7
|
+
A valid `<picture>` tag must contain an `<img>` tag, and a valid `<img>` tag
|
8
|
+
must contain a `src` with a single image. We call this the 'fallback' image.
|
9
|
+
|
10
|
+
## Fallback Width
|
11
|
+
|
12
|
+
_Format:_ `fallback_width: (integer)`
|
13
|
+
|
14
|
+
_Example:_ `fallback_width: 800`
|
15
|
+
|
16
|
+
_Default_: `800`
|
17
|
+
|
18
|
+
Width of the fallback image.
|
19
|
+
|
20
|
+
## Fallback Format
|
21
|
+
|
22
|
+
_Format:_ `fallback_format: (format)`
|
23
|
+
|
24
|
+
_Example:_ `fallback_format: jpg`
|
25
|
+
|
26
|
+
_Default_: `original`
|
27
|
+
|
28
|
+
Format of the fallback image.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
sort: 10
|
3
|
+
---
|
4
|
+
|
5
|
+
# Arbitrary HTML Attributes
|
6
|
+
|
7
|
+
_Format:_
|
8
|
+
|
9
|
+
```yaml
|
10
|
+
attributes:
|
11
|
+
(element): '(attributes)'
|
12
|
+
(...)
|
13
|
+
```
|
14
|
+
|
15
|
+
_Example:_
|
16
|
+
|
17
|
+
```yaml
|
18
|
+
attributes:
|
19
|
+
img: 'class="soopercool" data-awesomeness="11"'
|
20
|
+
picture: 'class="even-cooler"'
|
21
|
+
```
|
22
|
+
|
23
|
+
HTML attributes you would like to add. The same arguments are available here as
|
24
|
+
in the liquid tag: HTML element names, `alt:`, `link:`, and `parent:`. Unescaped
|
25
|
+
double quotes cause problems with yml, so it's recommended to surround them with
|
26
|
+
single quotes.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
sort: 4
|
3
|
+
---
|
4
|
+
|
5
|
+
# Image Formats
|
6
|
+
|
7
|
+
_Format:_ `formats: [format1, format2, (...)]`
|
8
|
+
|
9
|
+
_Example:_ `formats: [webp, original]`
|
10
|
+
|
11
|
+
_Default_: `original`
|
12
|
+
|
13
|
+
Array (yml sequence) of the image formats you'd like to generate, in decreasing
|
14
|
+
order of preference. Browsers will render the first format they find and
|
15
|
+
understand, so **If you put jpg before webp, your webp images will never be
|
16
|
+
used**. `original` does what you'd expect. To supply webp, you must have an
|
17
|
+
imagemagick webp delegate installed. (Most package managers just name it 'webp')
|
18
|
+
|
19
|
+
_Supported formats are anything which imagemagick supports, and has an installed
|
20
|
+
delegate. See a list by running `$ convert --version`_.
|
21
|
+
|
@@ -0,0 +1,120 @@
|
|
1
|
+
---
|
2
|
+
sort: 8
|
3
|
+
---
|
4
|
+
|
5
|
+
# Image Quality & Options
|
6
|
+
|
7
|
+
Image quality is set per-format, using `format_quality`.
|
8
|
+
|
9
|
+
## Constant Quality
|
10
|
+
|
11
|
+
_Format:_
|
12
|
+
|
13
|
+
```yaml
|
14
|
+
format_quality:
|
15
|
+
(format): 0 <= integer <= 100
|
16
|
+
(...)
|
17
|
+
```
|
18
|
+
|
19
|
+
_Example:_
|
20
|
+
|
21
|
+
```yaml
|
22
|
+
format_quality:
|
23
|
+
jpg: 75
|
24
|
+
png: 65
|
25
|
+
webp: 55
|
26
|
+
```
|
27
|
+
|
28
|
+
_Defaults:_
|
29
|
+
|
30
|
+
- webp - 50
|
31
|
+
- avif - 30
|
32
|
+
- jp2 - 30
|
33
|
+
- all others - 75
|
34
|
+
|
35
|
+
## Variable Quality
|
36
|
+
|
37
|
+
```yaml
|
38
|
+
format_quality:
|
39
|
+
(format):
|
40
|
+
(image width): (quality setting)
|
41
|
+
(image width): (quality setting)
|
42
|
+
```
|
43
|
+
|
44
|
+
_Example:_
|
45
|
+
|
46
|
+
```yaml
|
47
|
+
format_quality:
|
48
|
+
jpg:
|
49
|
+
1000: 65
|
50
|
+
300: 100
|
51
|
+
```
|
52
|
+
|
53
|
+
Set a variable image quality, based on image width. Provide exactly 2 image widths and associated
|
54
|
+
quality settings. Quality will be calculated as follows:
|
55
|
+
|
56
|
+
* For images smaller than the lowest image width, the setting for the lowest width is used.
|
57
|
+
* For images larger than the highest image width, the setting for the highest width is used.
|
58
|
+
* For images in between the 2, the quality setting will be linearly interpolated to some value in
|
59
|
+
between.
|
60
|
+
|
61
|
+
![](quality_width_graph.png)
|
62
|
+
|
63
|
+
Using this setting, you can get away with more compression on high pixel density screens without
|
64
|
+
sacrificing image quality for low-density screens. Taking the example settings above:
|
65
|
+
|
66
|
+
* A 1500px image will use a quality of 65.
|
67
|
+
* A 200px image will use a quality of 100.
|
68
|
+
* A 500px image will use a quality of 90.
|
69
|
+
|
70
|
+
## Strip Metadata
|
71
|
+
|
72
|
+
_Format:_ `strip_metadata: (true|false)`
|
73
|
+
|
74
|
+
_Example:_ `strip_metadata: false`
|
75
|
+
|
76
|
+
_Default:_ `true`
|
77
|
+
|
78
|
+
Remove EXIF data, which can save a few tens of kilobytes per image. This is set for all formats.
|
79
|
+
|
80
|
+
## Image Format Options
|
81
|
+
|
82
|
+
_Format:_
|
83
|
+
|
84
|
+
```yaml
|
85
|
+
image_options:
|
86
|
+
format:
|
87
|
+
setting1: value
|
88
|
+
setting2: value
|
89
|
+
(...)
|
90
|
+
(...)
|
91
|
+
```
|
92
|
+
|
93
|
+
_Example:_
|
94
|
+
|
95
|
+
```yaml
|
96
|
+
image_options:
|
97
|
+
webp:
|
98
|
+
lossless: true
|
99
|
+
```
|
100
|
+
|
101
|
+
_Default:_
|
102
|
+
|
103
|
+
```yaml
|
104
|
+
image_options:
|
105
|
+
avif:
|
106
|
+
compression: av1
|
107
|
+
speed: 8
|
108
|
+
```
|
109
|
+
|
110
|
+
Control the write options passed to libvips for each image output format. To see a list of options
|
111
|
+
available for a given image format, search for the method `vips_(format)save` in
|
112
|
+
[this](https://libvips.github.io/libvips/API/current/VipsForeignSave.html) API documentation. For
|
113
|
+
example, png options can be found by searching for `vips_pngsave()`, leading
|
114
|
+
[here](https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-pngsave). See the
|
115
|
+
optional arguments. `avif`'s options are under `vips_heifsave()`,
|
116
|
+
[here](https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-heifsave).
|
117
|
+
|
118
|
+
For all formats, note that
|
119
|
+
- `Q:` (quality) is handled by the settings above.
|
120
|
+
- `strip` is handled by the `strip_metadata` setting documented above.
|
@@ -0,0 +1,75 @@
|
|
1
|
+
---
|
2
|
+
sort: 3
|
3
|
+
---
|
4
|
+
|
5
|
+
# Presets
|
6
|
+
|
7
|
+
Presets are named collections of settings that determine basically everything
|
8
|
+
about JPT's output. Think of them like frameworks that you can plug images into;
|
9
|
+
the preset determines what markup, what image sizes, and what image formats to
|
10
|
+
create, while the picture tag determines which image(s) will be used. They are
|
11
|
+
stored in `_data/picture.yml`. You will have to create this file, and probably
|
12
|
+
the `_data/` directory as well.
|
13
|
+
|
14
|
+
Any settings which are specific to particular markup formats are documented on
|
15
|
+
their respective markup format page.
|
16
|
+
|
17
|
+
_General Format:_
|
18
|
+
|
19
|
+
```yaml
|
20
|
+
# _data/picture.yml
|
21
|
+
|
22
|
+
presets:
|
23
|
+
(name):
|
24
|
+
(option): (setting)
|
25
|
+
(option): (setting)
|
26
|
+
(...)
|
27
|
+
(...)
|
28
|
+
```
|
29
|
+
|
30
|
+
_Example:_
|
31
|
+
|
32
|
+
```yaml
|
33
|
+
# _data/picture.yml
|
34
|
+
|
35
|
+
presets:
|
36
|
+
default:
|
37
|
+
formats: [webp, original]
|
38
|
+
widths: [200, 400, 800, 1600]
|
39
|
+
link_source: true
|
40
|
+
|
41
|
+
lazy:
|
42
|
+
markup: data_auto
|
43
|
+
widths: [200, 400, 800, 1600]
|
44
|
+
link_source: true
|
45
|
+
noscript: true
|
46
|
+
```
|
47
|
+
|
48
|
+
## Media Queries
|
49
|
+
|
50
|
+
**Media queries are not presets**, but they are used when writing them. They are
|
51
|
+
defined in `_data/picture.yml` alongside presets. They look like this:
|
52
|
+
|
53
|
+
```yaml
|
54
|
+
# _data/picture.yml
|
55
|
+
|
56
|
+
media_queries:
|
57
|
+
(name): '(media query)'
|
58
|
+
(name): '(media query)'
|
59
|
+
(name): '(media query)'
|
60
|
+
```
|
61
|
+
|
62
|
+
Example:
|
63
|
+
|
64
|
+
```yaml
|
65
|
+
media_queries:
|
66
|
+
full_width: 'min-width: 901px'
|
67
|
+
tablet: 'min-width: 601px'
|
68
|
+
mobile: 'max-width: 600px'
|
69
|
+
```
|
70
|
+
|
71
|
+
More information [here](media_queries).
|
72
|
+
|
73
|
+
## Reference
|
74
|
+
|
75
|
+
{% include list.liquid %}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
sort: 12
|
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
|
+
```
|