jekyll_picture_tag 1.11.0 → 1.12.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/docs/Gemfile +4 -2
- data/docs/Gemfile.lock +14 -12
- data/docs/_config.yml +6 -10
- data/docs/devs/contributing/code.md +44 -0
- data/docs/devs/contributing/docs.md +13 -0
- data/docs/devs/contributing/index.md +15 -0
- data/docs/devs/contributing/setup.md +13 -0
- data/docs/devs/contributing/testing.md +41 -0
- data/docs/devs/index.md +7 -0
- data/docs/{releases.md → devs/releases.md} +24 -14
- data/docs/index.md +43 -27
- data/docs/users/configuration/cdn.md +35 -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/relative_urls.md +15 -0
- data/docs/users/configuration/suppress_warnings.md +16 -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 +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/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 +23 -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 +43 -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/width_height_attributes.md +34 -0
- data/docs/users/presets/width_srcsets.md +85 -0
- data/lib/jekyll_picture_tag/instructions/preset.rb +5 -1
- data/lib/jekyll_picture_tag/instructions/set.rb +5 -1
- data/lib/jekyll_picture_tag/version.rb +1 -1
- metadata +55 -14
- 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/usage.md +0 -157
@@ -0,0 +1,81 @@
|
|
1
|
+
---
|
2
|
+
---
|
3
|
+
# Examples
|
4
|
+
|
5
|
+
{% raw %}
|
6
|
+
|
7
|
+
* Basic form, will use the preset named 'default':
|
8
|
+
```
|
9
|
+
{% picture example.jpg %}
|
10
|
+
```
|
11
|
+
|
12
|
+
* Include alt text:
|
13
|
+
```
|
14
|
+
{% picture example.jpg --alt Alt Text %}
|
15
|
+
```
|
16
|
+
|
17
|
+
* Select a `preset` (defined in `_data/picture.yml`:
|
18
|
+
```
|
19
|
+
{% picture my_preset example.jpg %}
|
20
|
+
```
|
21
|
+
|
22
|
+
* Show different images on different devices. (Note that `mobile` must be set
|
23
|
+
to some media query under `media_queries:` in `_data/picture.yml`.
|
24
|
+
```
|
25
|
+
{% picture example.jpg mobile: example_cropped.jpg %}
|
26
|
+
```
|
27
|
+
|
28
|
+
* Use liquid variables:
|
29
|
+
```
|
30
|
+
{% picture {{ page.some_liquid_variable }} %}
|
31
|
+
```
|
32
|
+
|
33
|
+
* Select the blog_index preset, use liquid variables, and wrap the image in an
|
34
|
+
anchor tag (link):
|
35
|
+
```
|
36
|
+
{% picture blog_index {{ post.image }} --link {{ post.url }} %}
|
37
|
+
```
|
38
|
+
|
39
|
+
* Add arbitrary HTML attributes:
|
40
|
+
```
|
41
|
+
{% picture example.jpg --picture class="some classes" --img id="example" %}
|
42
|
+
```
|
43
|
+
|
44
|
+
```warning
|
45
|
+
Read the whole installation guide before using the crop feature.
|
46
|
+
```
|
47
|
+
|
48
|
+
* Crop to a 16:9 aspect ratio, keeping the top:
|
49
|
+
```
|
50
|
+
{% picture example.jpg 16:9 north %}
|
51
|
+
```
|
52
|
+
|
53
|
+
* Crop to a 1:1 aspect ratio, keeping the middle, with alt text:
|
54
|
+
```
|
55
|
+
{% picture thumbnail example.jpg 1:1 --alt Example Image %}
|
56
|
+
```
|
57
|
+
|
58
|
+
* Crop the same image multiple times:
|
59
|
+
```
|
60
|
+
{% picture example.jpg 16:9 tablet: example.jpg 4:3 mobile: example.jpg 1:1 %}
|
61
|
+
```
|
62
|
+
|
63
|
+
* Use filenames with spaces:
|
64
|
+
```
|
65
|
+
{% picture "some example.jpg" mobile: other\ example.jpg %}
|
66
|
+
```
|
67
|
+
|
68
|
+
* Use line breaks to make a complicated tag manageable:
|
69
|
+
```
|
70
|
+
{%
|
71
|
+
picture
|
72
|
+
hero
|
73
|
+
example.jpg 16:9 east
|
74
|
+
tablet: example2.jpg 3:2 east
|
75
|
+
mobile: example3.jpg 1:1-50+0 east
|
76
|
+
--alt Happy Puppy
|
77
|
+
--picture class="hero"
|
78
|
+
--link /
|
79
|
+
%}
|
80
|
+
```
|
81
|
+
{% endraw %}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
sort: 2
|
3
|
+
---
|
4
|
+
|
5
|
+
# Tag Usage
|
6
|
+
|
7
|
+
This section describes how to use JPT's liquid tag ({% raw %} `{% picture (...)
|
8
|
+
%}` {% endraw %}); what options it takes and what kind of information you can pass
|
9
|
+
through it to influence the the final HTML and generated images.
|
10
|
+
|
11
|
+
## Format
|
12
|
+
|
13
|
+
{% raw %}
|
14
|
+
`{% picture [preset] (image) [crop] [alternate images & crops] [attributes] %}`
|
15
|
+
{% endraw %}
|
16
|
+
|
17
|
+
The only required argument is the base image. Line breaks and extra spaces are
|
18
|
+
fine, and you can use liquid variables anywhere.
|
19
|
+
|
20
|
+
* `preset` - Select a recipe/blueprint from the ones you have defined in
|
21
|
+
`presets`. Will use `default` if not specified.
|
22
|
+
|
23
|
+
* `(image)` - required.
|
24
|
+
|
25
|
+
* `crop` - Geometry and gravity arguments, passed to imagemagick.
|
26
|
+
|
27
|
+
* `alternate images & crops` - Art Direction; show different images on different
|
28
|
+
devices. Give in order of ascending specificity.
|
29
|
+
|
30
|
+
* `attributes` - Add css classes, data-attributes, or wrap the whole thing in an
|
31
|
+
anchor tag.
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Git LFS
|
2
|
+
|
3
|
+
I'm Putting this here because it bit me: If you want to use git LFS, make sure that your hosting
|
4
|
+
provider makes those images available during the build process. Netlify, for example, does not.
|
5
|
+
You won't find this out until you have gone through the entire migration process and try to deploy
|
6
|
+
for the first time.
|
7
|
+
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# Github Pages?
|
2
|
+
|
3
|
+
Github Pages only allows a very short whitelist of plugins, which sadly does not include JPT. You
|
4
|
+
can either run it locally, then commit and push the generated files (rather than the source
|
5
|
+
files), or just host it some other way. I recommend Netlify.
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# Getting cryptic build errors?
|
2
|
+
|
3
|
+
Jekyll Picture Tag is very trusting. It doesn't do much checking of your inputs, and it does not
|
4
|
+
fail gracefully if you for example pass it a string when it expects an array. It's on the to-do
|
5
|
+
list, but for now if you get cryptic errors then double-check your settings and tag arguments.
|
6
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Extra {::nomarkdown} tags or mangled HTML?
|
2
|
+
|
3
|
+
## TLDR up front
|
4
|
+
|
5
|
+
There's a bug involving `<picture>` tags wrapped in `<a>` tags which is not in
|
6
|
+
my power to fix.
|
7
|
+
|
8
|
+
* If you're getting extra `{::nomarkdown}` tags floating around your images, add `nomarkdown:
|
9
|
+
false` 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:
|
12
|
+
true` 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.**
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Managing Generated Images
|
2
|
+
|
3
|
+
Jekyll Picture Tag creates resized versions of your images when you build the
|
4
|
+
site. It uses a caching system to speed up site compilation, and re-uses images
|
5
|
+
as much as possible. Filenames take the following format:
|
6
|
+
|
7
|
+
`(original name without extension)-(width)-(id-string).(filetype)`
|
8
|
+
|
9
|
+
Try to use a base image that is larger than the largest resized image you need.
|
10
|
+
Jekyll Picture Tag will warn you if a base image is too small, and won't upscale
|
11
|
+
images.
|
12
|
+
|
13
|
+
By specifying a `source` directory that is ignored by Jekyll you can prevent
|
14
|
+
huge base images from being copied to the compiled site. For example, `source:
|
15
|
+
assets/images/_fullsize` and `output: generated` will result in a compiled site
|
16
|
+
that contains resized images but not the originals. Note that this will break
|
17
|
+
source image linking, if you wish to enable it. (Can't link to images that
|
18
|
+
aren't public!)
|
19
|
+
|
20
|
+
The `output` directory is never deleted by Jekyll. You may want to empty it once
|
21
|
+
in awhile, to clear out unused images.
|
File without changes
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
sort: 5
|
3
|
+
---
|
4
|
+
|
5
|
+
# Cropping
|
6
|
+
|
7
|
+
**Check the warning in the
|
8
|
+
[installation guide]({{ site.baseurl }}/users/installation)
|
9
|
+
before using this feature.**
|
10
|
+
|
11
|
+
## Crop & Media Crop
|
12
|
+
|
13
|
+
_Format:_
|
14
|
+
|
15
|
+
```yaml
|
16
|
+
crop: (geometery)
|
17
|
+
media_crop:
|
18
|
+
(media_preset): (geometry)
|
19
|
+
(media_preset): (geometry)
|
20
|
+
(...)
|
21
|
+
```
|
22
|
+
|
23
|
+
_Example:_
|
24
|
+
|
25
|
+
```yaml
|
26
|
+
crop: 16:9
|
27
|
+
media_crop:
|
28
|
+
tablet: 3:2
|
29
|
+
mobile: 1:1
|
30
|
+
```
|
31
|
+
|
32
|
+
Crop geometry, given either generally or for specific media presets. The
|
33
|
+
hierarchy is: `tag argument` > `media_crop:` > `crop:`.
|
34
|
+
|
35
|
+
This setting accepts the same arguments as the `crop geometry`
|
36
|
+
[tag parameter]({{ site.baseurl }}/users/liquid_tag/argument_reference/crop).
|
37
|
+
|
38
|
+
## Gravity & Media Gravity
|
39
|
+
|
40
|
+
```yaml
|
41
|
+
gravity: (gravity)
|
42
|
+
media_gravity:
|
43
|
+
(media_preset): (gravity)
|
44
|
+
(media_preset): (gravity)
|
45
|
+
(...)
|
46
|
+
```
|
47
|
+
|
48
|
+
_Example:_
|
49
|
+
|
50
|
+
```yaml
|
51
|
+
gravity: north
|
52
|
+
media_gravity:
|
53
|
+
tablet: east
|
54
|
+
mobile: southwest
|
55
|
+
```
|
56
|
+
|
57
|
+
Crop gravity, given either generally or for specific media presets. The hierarchy is:
|
58
|
+
`tag argument` > `media_gravity:` > `gravity:` > `center` (default).
|
59
|
+
|
60
|
+
This setting accepts the same arguments as the `crop gravity`
|
61
|
+
[tag parameter]({{ site.baseurl }}/users/liquid_tag/argument_reference/crop).
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
sort: 13
|
3
|
+
---
|
4
|
+
|
5
|
+
# Default preset
|
6
|
+
|
7
|
+
Here are the default preset settings:
|
8
|
+
|
9
|
+
```yml
|
10
|
+
presets:
|
11
|
+
default:
|
12
|
+
markup: auto
|
13
|
+
formats: [original]
|
14
|
+
widths: [400, 600, 800, 1000]
|
15
|
+
fallback_width: 800
|
16
|
+
fallback_format: original
|
17
|
+
noscript: false
|
18
|
+
link_source: false
|
19
|
+
quality: 75
|
20
|
+
data_sizes: true
|
21
|
+
gravity: center
|
22
|
+
dimension_attributes: false
|
23
|
+
```
|
@@ -0,0 +1,79 @@
|
|
1
|
+
---
|
2
|
+
sort: 12
|
3
|
+
---
|
4
|
+
# Example _data/picture.yml
|
5
|
+
|
6
|
+
These are example settings- I mostly made them up off the top of my head. You
|
7
|
+
probably don't want to just copy-paste them.
|
8
|
+
|
9
|
+
```yaml
|
10
|
+
# _data/picture.yml
|
11
|
+
|
12
|
+
media_queries:
|
13
|
+
wide_desktop: 'min-width: 1801px'
|
14
|
+
desktop: 'max-width: 1800px'
|
15
|
+
wide_tablet: 'max-width: 1200px'
|
16
|
+
tablet: 'max-width: 900px'
|
17
|
+
mobile: 'max-width: 600px'
|
18
|
+
|
19
|
+
presets:
|
20
|
+
default:
|
21
|
+
markup: auto
|
22
|
+
link_source: true # wrap images in a link to the original source image.
|
23
|
+
dimension_attributes: true # Page reflow begone!
|
24
|
+
|
25
|
+
formats: [webp, original] # Must be an array, and order matters.
|
26
|
+
|
27
|
+
widths: [200, 400, 800, 1600] # Must be an array.
|
28
|
+
media_widths: # Because a cell phone doesn't want 1600 pixels.
|
29
|
+
mobile: [200, 400, 600]
|
30
|
+
tablet: [400, 600, 800]
|
31
|
+
|
32
|
+
sizes:
|
33
|
+
mobile: 100vw
|
34
|
+
tablet: 80vw
|
35
|
+
size: 800px
|
36
|
+
|
37
|
+
fallback_width: 800
|
38
|
+
fallback_format: original
|
39
|
+
|
40
|
+
attributes:
|
41
|
+
parent: 'data-downloadable="true"'
|
42
|
+
picture: 'class="awesome" data-volume="11"'
|
43
|
+
img: 'class="some-other-class"'
|
44
|
+
a: 'class="image-link"'
|
45
|
+
|
46
|
+
# This is an example of how you would create a 'multiplier' based srcset;
|
47
|
+
# useful when an image will always be the same size on all screens (icons,
|
48
|
+
# graphics, thumbnails, etc), but you'd like to supply higher resolution
|
49
|
+
# images to devices with higher pixel ratios.
|
50
|
+
icon:
|
51
|
+
base_width: 20 # How wide the 1x image should be.
|
52
|
+
pixel_ratios: [1, 1.5, 2]
|
53
|
+
fallback_width: 20
|
54
|
+
attributes:
|
55
|
+
img: 'class="icon"'
|
56
|
+
|
57
|
+
# Here's an example of how you'd configure jekyll-picture-tag to work with
|
58
|
+
# something like lazyload: https://github.com/verlok/lazyload
|
59
|
+
lazy:
|
60
|
+
markup: data_auto
|
61
|
+
formats: [webp, original]
|
62
|
+
widths: [200, 400, 600, 800]
|
63
|
+
noscript: true # add a fallback image inside a <noscript> tag.
|
64
|
+
attributes:
|
65
|
+
img: class="lazy"
|
66
|
+
|
67
|
+
# This is an example of how you'd get generated image and a URL, and nothing
|
68
|
+
# else.
|
69
|
+
direct:
|
70
|
+
markup: direct_url
|
71
|
+
fallback_format: webp
|
72
|
+
fallback_width: 600
|
73
|
+
|
74
|
+
# Here's a naked srcset. Doesn't even give you the surrounding quotes.
|
75
|
+
srcset:
|
76
|
+
markup: naked_srcset
|
77
|
+
formats: [webp] # must be an array, even if it only has one item
|
78
|
+
|
79
|
+
```
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
sort: 9
|
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: 8
|
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.
|