jekyll_picture_tag 1.10.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.envrc +2 -0
- data/.github/workflows/code-checks.yml +43 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +30 -0
- 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 +46 -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 +34 -0
- data/docs/devs/index.md +7 -0
- data/docs/{releases.md → devs/releases.md} +44 -15
- data/docs/index.md +42 -26
- 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/index.md +7 -0
- data/docs/users/installation.md +52 -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 +48 -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 +93 -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/input_checking.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.md} +0 -0
- data/docs/users/presets/cropping.md +61 -0
- data/docs/users/presets/default.md +24 -0
- data/docs/users/presets/examples.md +79 -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 +105 -0
- data/docs/users/presets/index.md +101 -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/strip_metadata.md +13 -0
- data/docs/users/presets/width_height_attributes.md +34 -0
- data/docs/users/presets/width_srcsets.md +85 -0
- data/install_imagemagick.sh +23 -0
- data/jekyll_picture_tag.gemspec +10 -6
- data/lib/jekyll_picture_tag.rb +5 -5
- data/lib/jekyll_picture_tag/cache.rb +3 -0
- data/lib/jekyll_picture_tag/cache/base.rb +61 -0
- data/lib/jekyll_picture_tag/cache/generated.rb +20 -0
- data/lib/jekyll_picture_tag/cache/source.rb +19 -0
- 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/images.rb +3 -0
- data/lib/jekyll_picture_tag/images/generated_image.rb +130 -0
- data/lib/jekyll_picture_tag/{img_uri.rb → images/img_uri.rb} +4 -1
- data/lib/jekyll_picture_tag/images/source_image.rb +103 -0
- data/lib/jekyll_picture_tag/instructions/arg_splitter.rb +3 -2
- data/lib/jekyll_picture_tag/instructions/preset.rb +24 -4
- data/lib/jekyll_picture_tag/instructions/set.rb +5 -1
- data/lib/jekyll_picture_tag/output_formats/basic.rb +16 -14
- data/lib/jekyll_picture_tag/output_formats/img.rb +11 -0
- data/lib/jekyll_picture_tag/output_formats/picture.rb +22 -0
- data/lib/jekyll_picture_tag/router.rb +3 -2
- data/lib/jekyll_picture_tag/srcsets/basic.rb +10 -1
- data/lib/jekyll_picture_tag/utils.rb +14 -0
- data/lib/jekyll_picture_tag/version.rb +1 -1
- data/readme.md +13 -10
- metadata +139 -46
- data/.travis.yml +0 -8
- 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 -361
- data/docs/usage.md +0 -143
- data/lib/jekyll_picture_tag/generated_image.rb +0 -161
- data/lib/jekyll_picture_tag/source_image.rb +0 -87
data/docs/installation.md
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
---
|
2
|
-
---
|
3
|
-
|
4
|
-
# Installation
|
5
|
-
|
6
|
-
- Add `jekyll_picture_tag` to your Gemfile in the `:jekyll_plugins` group:
|
7
|
-
|
8
|
-
```ruby
|
9
|
-
group :jekyll_plugins do
|
10
|
-
gem 'jekyll_picture_tag'
|
11
|
-
end
|
12
|
-
```
|
13
|
-
|
14
|
-
- Run `$ bundle install`
|
15
|
-
|
16
|
-
- See if you have ImageMagick with `$ convert --version`. You should see something like this:
|
17
|
-
|
18
|
-
```
|
19
|
-
~ $ convert --version
|
20
|
-
Version: ImageMagick 7.0.8-14 Q16 x86_64 2018-10-31 https://imagemagick.org
|
21
|
-
Copyright: © 1999-2018 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php
|
22
|
-
Features: Cipher DPC HDRI OpenMP Delegates (built-in): bzlib fontconfig freetype jng jp2 jpeg lcms
|
23
|
-
lzma pangocairo png tiff webp xml zlib
|
24
|
-
```
|
25
|
-
|
26
|
-
If you get a 'command not found' error, you'll need to install it. Most package managers know about
|
27
|
-
ImageMagick, otherwise it can be found [here](https://imagemagick.org/script/download.php).
|
28
|
-
|
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).
|
44
|
-
|
45
|
-
Once I work out how to actually do that, I'll add some guidance here.
|
data/docs/notes.md
DELETED
@@ -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.
|
data/docs/output.md
DELETED
@@ -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.
|
data/docs/presets.md
DELETED
@@ -1,361 +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
|
-
* **Image Formats**
|
103
|
-
|
104
|
-
_Format:_ `format: [format1, format2, (...)]`
|
105
|
-
|
106
|
-
_Example:_ `format: [webp, original]`
|
107
|
-
|
108
|
-
_Default_: `original`
|
109
|
-
|
110
|
-
Array (yml sequence) of the image formats you'd like to generate, in decreasing order of
|
111
|
-
preference. Browsers will render the first format they find and understand, so **If you put jpg
|
112
|
-
before webp, your webp images will never be used**. `original` does what you'd expect. To supply
|
113
|
-
webp, you must have an imagemagick webp delegate installed. (Most package managers just name it
|
114
|
-
'webp')
|
115
|
-
|
116
|
-
_Supported formats are anything which imagemagick supports, and has an installed delegate. See a
|
117
|
-
list by running `$ convert --version`_
|
118
|
-
|
119
|
-
* **Widths**
|
120
|
-
|
121
|
-
_Format:_ `widths: [integer, integer, (...)]`
|
122
|
-
|
123
|
-
_Example:_ `widths: [600, 800, 1200]`
|
124
|
-
|
125
|
-
_Default_: `[400, 600, 800, 1000]`
|
126
|
-
|
127
|
-
Array of image widths to generate, in pixels. For use when you want a width-based srcset
|
128
|
-
(`srcset="img.jpg 800w, img2.jpg 1600w"`).
|
129
|
-
|
130
|
-
* **Media_widths**
|
131
|
-
|
132
|
-
_Format:_
|
133
|
-
|
134
|
-
```yml
|
135
|
-
media_widths:
|
136
|
-
(media preset name): [integer, integer, (...)]
|
137
|
-
```
|
138
|
-
|
139
|
-
_Example:_
|
140
|
-
|
141
|
-
```yml
|
142
|
-
media_widths:
|
143
|
-
mobile: [400, 600, 800]
|
144
|
-
```
|
145
|
-
|
146
|
-
_Default:_ Widths setting
|
147
|
-
|
148
|
-
If you are using art direction, there is no sense in generating desktop-size files for your mobile
|
149
|
-
image. You can specify sets of widths to associate with given media queries. If not specified,
|
150
|
-
will use `widths` setting.
|
151
|
-
|
152
|
-
* **Sizes**
|
153
|
-
|
154
|
-
_Format:_
|
155
|
-
|
156
|
-
```yml
|
157
|
-
sizes:
|
158
|
-
(media preset): (CSS dimension)
|
159
|
-
(...)
|
160
|
-
```
|
161
|
-
|
162
|
-
_Example:_
|
163
|
-
|
164
|
-
```yml
|
165
|
-
sizes:
|
166
|
-
mobile: 80vw
|
167
|
-
tablet: 60vw
|
168
|
-
desktop: 900px
|
169
|
-
```
|
170
|
-
|
171
|
-
Conditional sizes, used to construct the `sizes=` HTML attribute telling the browser how wide your
|
172
|
-
image will be (on the screen) when a given media query is true. CSS dimensions can be given in
|
173
|
-
`px`, `em`, or `vw`. To be used along with a width-based srcset.
|
174
|
-
|
175
|
-
Provide these in order of most restrictive to least restrictive. The browser will choose the
|
176
|
-
first one with an applicable media query.
|
177
|
-
|
178
|
-
You don't have to provide a sizes attribute at all. If you don't, the browser will assume the
|
179
|
-
image is 100% the width of the viewport.
|
180
|
-
|
181
|
-
* **Size**
|
182
|
-
|
183
|
-
_Format:_ `size: (CSS Dimension)`
|
184
|
-
|
185
|
-
_Example:_ `size: 80vw`
|
186
|
-
|
187
|
-
Unconditional `sizes` setting, to be supplied either alone or after all conditional sizes.
|
188
|
-
|
189
|
-
* **Pixel Ratios**
|
190
|
-
|
191
|
-
_Format:_ `pixel_ratios: [number, number, number (...)]`
|
192
|
-
|
193
|
-
_Example:_ `pixel_ratios: [1, 1.5, 2]`
|
194
|
-
|
195
|
-
Array of images to construct, given in multiples of the base width. If you set this, you must also
|
196
|
-
give a `base_width`.
|
197
|
-
|
198
|
-
Set this when you want a multiplier based srcset (example: `srcset="img.jpg 1x, img2.jpg 2x"`).
|
199
|
-
|
200
|
-
* **Base Width**
|
201
|
-
|
202
|
-
_Format:_ `base_width: integer`
|
203
|
-
|
204
|
-
_Example:_ `base_width: 100`
|
205
|
-
|
206
|
-
When using pixel ratios, you must supply a base width. This sets how wide the 1x image should be.
|
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
|
-
|
261
|
-
* **Quality**
|
262
|
-
|
263
|
-
_Format:_ `quality: 0 <= integer <= 100`
|
264
|
-
|
265
|
-
_Example:_ `quality: 80`
|
266
|
-
|
267
|
-
_Default:_ `75`
|
268
|
-
|
269
|
-
This allows you to specify an image compression level for all image formats (where it makes sense,
|
270
|
-
anyway). The next option allows you to set them per format.
|
271
|
-
|
272
|
-
* **Format Quality**
|
273
|
-
|
274
|
-
_Format:_
|
275
|
-
|
276
|
-
```yml
|
277
|
-
format_quality:
|
278
|
-
(format): 0 <= integer <= 100
|
279
|
-
(...)
|
280
|
-
```
|
281
|
-
|
282
|
-
_Example:_
|
283
|
-
|
284
|
-
```
|
285
|
-
format_quality:
|
286
|
-
jpg: 75
|
287
|
-
png: 65
|
288
|
-
webp: 55
|
289
|
-
```
|
290
|
-
|
291
|
-
_Default:_ quality setting (above)
|
292
|
-
|
293
|
-
This allows you to specify quality settings for various image formats, allowing you to take
|
294
|
-
advantage of webp's better compression algorithm without trashing your jpg images (for example).
|
295
|
-
If you don't give a setting for a particular format it'll fall back to the `quality` setting
|
296
|
-
above, and if you don't set _that_ it'll default to 75.
|
297
|
-
|
298
|
-
* **HTML Attributes**
|
299
|
-
|
300
|
-
_Format:_
|
301
|
-
|
302
|
-
```yml
|
303
|
-
attributes:
|
304
|
-
(element): '(attributes)'
|
305
|
-
(...)
|
306
|
-
```
|
307
|
-
|
308
|
-
_Example:_
|
309
|
-
|
310
|
-
```yml
|
311
|
-
attributes:
|
312
|
-
img: 'class="soopercool" data-awesomeness="11"'
|
313
|
-
picture: 'class="even-cooler"'
|
314
|
-
```
|
315
|
-
|
316
|
-
HTML attributes you would like to add. The same arguments are available here as in the liquid
|
317
|
-
tag: HTML element names, `alt:`, `link:`, and `parent:`. Unescaped double quotes cause problems
|
318
|
-
with yml, so it's recommended to surround them with single quotes.
|
319
|
-
|
320
|
-
* **Fallback Width**
|
321
|
-
|
322
|
-
_Format:_ `fallback_width: (integer)`
|
323
|
-
|
324
|
-
_Example:_ `fallback_width: 800`
|
325
|
-
|
326
|
-
_Default_: `800`
|
327
|
-
|
328
|
-
Width of the fallback image.
|
329
|
-
|
330
|
-
* **Fallback Format**
|
331
|
-
|
332
|
-
_Format:_ `fallback_format: (format)`
|
333
|
-
|
334
|
-
_Example:_ `fallback_format: jpg`
|
335
|
-
|
336
|
-
_Default_: `original`
|
337
|
-
|
338
|
-
Format of the fallback image
|
339
|
-
|
340
|
-
* **Source Image Link**
|
341
|
-
|
342
|
-
_Format:_ `link_source: (true|false)`
|
343
|
-
|
344
|
-
_Example:_ `link_source: true`
|
345
|
-
|
346
|
-
_Default:_ `false`
|
347
|
-
|
348
|
-
Surround image with a link to the original source file. Your source image directory must be
|
349
|
-
published as part of the compiled site. If you run into weird issues with the output, see
|
350
|
-
the [notes]({{ site.baseurl }}/notes).
|
351
|
-
|
352
|
-
* **Nomarkdown override**
|
353
|
-
|
354
|
-
_Format:_ `nomarkdown: (true|false)`
|
355
|
-
|
356
|
-
_Example:_ `nomarkdown: false`
|
357
|
-
|
358
|
-
_Default:_ `nil`
|
359
|
-
|
360
|
-
Hard setting for `{::nomarkdown}` tags, overrides both autodetection and the global setting in
|
361
|
-
`_config.yml`. See the [notes]({{ site.baseurl }}/notes) for a detailed explanation.
|