jekyll_picture_tag 1.7.0 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.solargraph.yml +15 -0
  4. data/.travis.yml +4 -7
  5. data/Dockerfile +9 -0
  6. data/docs/Gemfile +4 -0
  7. data/docs/Gemfile.lock +249 -0
  8. data/docs/_config.yml +13 -0
  9. data/docs/_layouts/directory.html +32 -0
  10. data/docs/assets/style.css +31 -0
  11. data/{contributing.md → docs/contributing.md} +57 -15
  12. data/docs/{examples/_data/picture.yml → example_presets.md} +36 -25
  13. data/docs/global_configuration.md +61 -3
  14. data/docs/index.md +114 -0
  15. data/docs/installation.md +36 -21
  16. data/docs/migration.md +4 -0
  17. data/docs/notes.md +64 -58
  18. data/docs/output.md +63 -0
  19. data/docs/presets.md +175 -221
  20. data/docs/releases.md +64 -0
  21. data/docs/usage.md +91 -79
  22. data/jekyll_picture_tag.gemspec +3 -1
  23. data/lib/jekyll_picture_tag.rb +27 -10
  24. data/lib/jekyll_picture_tag/defaults/global.yml +2 -0
  25. data/lib/jekyll_picture_tag/defaults/presets.yml +2 -0
  26. data/lib/jekyll_picture_tag/generated_image.rb +105 -19
  27. data/lib/jekyll_picture_tag/instructions.rb +1 -0
  28. data/lib/jekyll_picture_tag/instructions/arg_splitter.rb +68 -0
  29. data/lib/jekyll_picture_tag/instructions/configuration.rb +47 -11
  30. data/lib/jekyll_picture_tag/instructions/html_attributes.rb +14 -8
  31. data/lib/jekyll_picture_tag/instructions/preset.rb +34 -14
  32. data/lib/jekyll_picture_tag/instructions/set.rb +18 -8
  33. data/lib/jekyll_picture_tag/instructions/tag_parser.rb +59 -69
  34. data/lib/jekyll_picture_tag/output_formats/basic.rb +35 -6
  35. data/lib/jekyll_picture_tag/output_formats/data_attributes.rb +4 -1
  36. data/lib/jekyll_picture_tag/router.rb +16 -0
  37. data/lib/jekyll_picture_tag/source_image.rb +6 -1
  38. data/lib/jekyll_picture_tag/srcsets/basic.rb +45 -19
  39. data/lib/jekyll_picture_tag/srcsets/pixel_ratio.rb +1 -3
  40. data/lib/jekyll_picture_tag/srcsets/width.rb +1 -1
  41. data/lib/jekyll_picture_tag/utils.rb +18 -0
  42. data/lib/jekyll_picture_tag/version.rb +1 -1
  43. data/readme.md +43 -200
  44. metadata +49 -13
  45. data/docs/examples/_config.yml +0 -10
  46. data/docs/examples/post.md +0 -46
  47. data/docs/readme.md +0 -23
@@ -1,7 +1,12 @@
1
- # These are example settings. I mostly made them up off the top of my head. You
2
- # probably don't want to just copy-paste these settings. It's worth your time to
3
- # learn responsive images, so you'll understand what these settings mean.
4
- # The full documentation for these settings can be found in docs/presets.md
1
+ ---
2
+ ---
3
+ # /_data/picture.yml
4
+
5
+ These are example settings- I mostly made them up off the top of my head. You
6
+ probably don't want to just copy-paste them. The full documentation
7
+ for these can be found [here]({{ site.baseurl }}/presets).
8
+
9
+ ```yml
5
10
 
6
11
  # Media presets are just named css media queries, used in several places:
7
12
  # - To specify alternate source images (for art direction)
@@ -14,44 +19,47 @@ media_presets:
14
19
  tablet: 'max-width: 900px'
15
20
  mobile: 'max-width: 600px'
16
21
 
17
- # Markup presets allow you to group settings together, and select one of them by name in your jekyll
18
- # tag. All settings are optional.
22
+ # Markup presets allow you to group settings together, and select one of them by
23
+ # name in your jekyll tag. All settings are optional.
19
24
  markup_presets:
20
- # If you don't specify a preset in the liquid tag (just say
21
- # {% picture image.jpg %}), you'll get the 'default' preset:
25
+
22
26
  default:
23
- # What form the output markup should take.
27
+ # What form the output markup should take:
24
28
  markup: auto
25
29
 
26
30
  # Must be an array, and order matters. Defaults to just 'original', which
27
31
  # does what you'd expect.
28
32
  formats: [webp, original]
29
33
 
30
- # Must be an array: which image sizes (width in pixels) to generate (unless directed otherwise
31
- # below). If not specified, will use sensible default values.
34
+ # Must be an array: which image sizes (width in pixels) to generate (unless
35
+ # directed otherwise below). If not specified, will use sensible default
36
+ # values.
32
37
  widths: [200, 400, 800, 1600]
33
38
 
34
- # Alternate source images (for art direction) are associated with media query presets. Here, you
35
- # can optionally specify a different set of sizes to generate for those alternate source images.
36
- # This is how you avoid generating a 1600 pixel wide image that's only shown on narrow screens.
39
+ # Alternate source images (for art direction) are associated with media
40
+ # query presets. Here, you can optionally specify a different set of sizes
41
+ # to generate for those alternate source images. This is how you avoid
42
+ # generating a 1600 pixel wide image that's only shown on narrow screens.
37
43
  # Must be arrays.
38
44
  media_widths:
39
45
  mobile: [200, 400, 600]
40
46
  tablet: [400, 600, 800]
41
47
 
42
- # For building the 'sizes' attribute on img and source tags. specifies how wide the image will
43
- # be when a given media query is true. Note that every source in a given <picture> tag will have
44
- # the same associated sizes attribute.
48
+ # For building the 'sizes' attribute on img and source tags. specifies how
49
+ # wide the image will be when a given media query is true. Note that every
50
+ # source in a given <picture> tag will have the same associated sizes
51
+ # attribute.
45
52
  sizes:
46
53
  mobile: 100vw
47
54
  tablet: 80vw
48
55
 
49
- # Specifies an optional, unconditional size attribute. Can be given alone, or if specified in
50
- # combination with 'sizes' below, will be given last (when no media queries apply).
56
+ # Specifies an optional, unconditional size attribute. Can be given alone,
57
+ # or if specified in combination with 'sizes' below, will be given last
58
+ # (when no media queries apply).
51
59
  size: 800px
52
60
 
53
- # Specify the properties of the fallback image. If not specified, will return a 900 pixel
54
- # wide image in the original format.
61
+ # Specify the properties of the fallback image. If not specified, will
62
+ # return a 900 pixel wide image in the original format.
55
63
  fallback_width: 800
56
64
  fallback_format: original
57
65
 
@@ -67,7 +75,7 @@ markup_presets:
67
75
  # your source images will need to be part of the deployed site for this to
68
76
  # work. If you have issues such as mangled HTML or extra {::nomarkdown}
69
77
  # tags floating around, see docs/notes.md
70
- link-source: true
78
+ link_source: true
71
79
 
72
80
  # This is an example of how you would create a 'multiplier' based srcset;
73
81
  # useful when an image will always be the same size on all screens (icons,
@@ -80,8 +88,8 @@ markup_presets:
80
88
  attributes:
81
89
  img: 'class="icon"'
82
90
 
83
- # Here's an example of how you'd configure jekyll-picture-tag to work with something like
84
- # lazyload:
91
+ # Here's an example of how you'd configure jekyll-picture-tag to work with
92
+ # something like lazyload:
85
93
  # https://github.com/verlok/lazyload
86
94
  lazy:
87
95
  # data_auto gives you data-src, data-srcset, and data-sizes instead of src,
@@ -93,7 +101,8 @@ markup_presets:
93
101
  attributes:
94
102
  img: class="lazy"
95
103
 
96
- # This is an example of how you'd get generated image and a URL, and nothing else.
104
+ # This is an example of how you'd get generated image and a URL, and nothing
105
+ # else.
97
106
  direct:
98
107
  markup: direct_url
99
108
  fallback_format: webp # Default original
@@ -103,3 +112,5 @@ markup_presets:
103
112
  srcset:
104
113
  markup: naked_srcset
105
114
  formats: [webp] # must be an array, even if it only has one item
115
+
116
+ ```
@@ -1,3 +1,5 @@
1
+ ---
2
+ ---
1
3
  # Global Configuration
2
4
 
3
5
  **All configuration is optional**. If you are happy with the defaults, you don't have to touch a
@@ -24,8 +26,10 @@ picture:
24
26
  To make writing tags easier you can specify a source directory for your assets. Base images in the
25
27
  tag will be relative to the `source` directory, which is relative to the Jekyll site root.
26
28
 
29
+ {% raw %}
27
30
  For example, if `source` is set to `assets/images/_fullsize`, the tag
28
31
  `{% picture enishte/portrait.jpg --alt An unsual picture %}` will look for a file at
32
+ {% endraw %}
29
33
  `assets/images/_fullsize/enishte/portrait.jpg`.
30
34
 
31
35
  * **Destination Image Directory**
@@ -61,7 +65,12 @@ picture:
61
65
 
62
66
  *Default:* `false`
63
67
 
64
- Normally, JPT will raise an error if a source image is missing, causing the entire site build to fail. This setting allows you to bypass this behavior and continue the build, either for certain build environments or all the time. I highly encourage you to set this to `development`, and set the jekyll build environment to `production` when you build for production so you don't shoot yourself in the foot (publish a site with broken images). You can read more about Jekyll environments [here](https://jekyllrb.com/docs/configuration/environments/).
68
+ Normally, JPT will raise an error if a source image is missing, causing the entire site build to
69
+ fail. This setting allows you to bypass this behavior and continue the build, either for certain
70
+ build environments or all the time. I highly encourage you to set this to `development`, and set
71
+ the jekyll build environment to `production` when you build for production so you don't shoot
72
+ yourself in the foot (publish a site with broken images). You can read more about Jekyll
73
+ environments [here](https://jekyllrb.com/docs/configuration/environments/).
65
74
 
66
75
  * **Use Relative Urls**
67
76
 
@@ -107,9 +116,58 @@ picture:
107
116
 
108
117
  *Example:* `nomarkdown: false`
109
118
 
110
- *Default*: `true`
119
+ *Default:* `true`
111
120
 
112
121
  Whether or not to surround j-p-t's output with a `{::nomarkdown}..{:/nomarkdown}` block when called
113
122
  from within a markdown file.
114
123
 
115
- This setting is overridden by the same setting in a preset. See [this wiki page](https://github.com/rbuchberger/jekyll_picture_tag/wiki/Extra-%7B::nomarkdown%7D-tags-or-mangled-html%3F) for more detailed information.
124
+ This setting is overridden by the same setting in a preset. See [the notes]({{ site.baseurl
125
+ }}/notes) for more detailed information.
126
+
127
+ * **Fast Build**
128
+
129
+ *Format:* `fast_build: (true|false|environment|array of environments)`
130
+
131
+ *Examples:*
132
+
133
+ - `fast_build: true`
134
+
135
+ - `fast_build: development`
136
+
137
+ - `fast_build: [development, staging]`
138
+
139
+ *Default:* `false`
140
+
141
+ Makes a tradeoff: Speeds repeated build times for sites with many images, by assuming that the
142
+ filename alone is enough to uniquely identify a source image. This doesn't speed up image
143
+ generation, just detection of whether or not it's necessary.
144
+
145
+ Ordinarily, JPT generates an MD5 hash for every source image, every site build. This ensures that
146
+ if you replace one image with another, but keep the filename the same, JPT will correctly generate
147
+ images for the new file. If you have many large images and/or limited hardware, this can take some
148
+ time and make the development process painful. Enable this setting to skip MD5 hash checking on
149
+ existing generated images (most of the time), and just assume that if the filename, format, and
150
+ width match then it's the right one. If there are multiple possible matches (resulting from
151
+ leftover generated images from previous filename replacements), it'll compute a hash instead of
152
+ guessing randomly.
153
+
154
+ * **Disable Jekyll Picture Tag**
155
+
156
+ *Format:* `disabled: (true|false|environment|array of environments)`
157
+
158
+ *Examples:*
159
+
160
+ - `disabled: true`
161
+
162
+ - `disabled: development`
163
+
164
+ - `disabled: [development, staging]`
165
+
166
+ *Default:* `false`
167
+
168
+ Disable image and markup generation entirely. Useful for debugging, or to speed up site builds
169
+ when you're working on something else.
170
+
171
+ Hint: If you're going to toggle this on and off frequently, you might just use an environment
172
+ variable. Set this to something like `nopics`, and then start the Jekyll server with something
173
+ like `JEKYLL_ENV=nopics bundle exec jekyll serve` when you don't want image generation.
@@ -0,0 +1,114 @@
1
+ ---
2
+ id: quickstart
3
+ ---
4
+
5
+ # Quick start / Demo
6
+
7
+ **All configuration is optional.** Here's the simplest possible use case:
8
+
9
+ 1. [Install]({{ site.baseurl }}/installation)
10
+
11
+ 2. Write this: {% raw %} `{% picture test.jpg %}` {% endraw %}
12
+
13
+ 3. Get this:
14
+
15
+ ```html
16
+ <!-- Formatted for readability -->
17
+
18
+ <img src="/generated/test-800-195f7d.jpg"
19
+ srcset="
20
+ /generated/test-400-195f7d.jpg 400w,
21
+ /generated/test-600-195f7d.jpg 600w,
22
+ /generated/test-800-195f7d.jpg 800w,
23
+ /generated/test-1000-195f7d.jpg 1000w
24
+ ">
25
+ ```
26
+
27
+ (Along with the appropriate images, obviously.)
28
+
29
+ ### "That's cool, but I just want webp."
30
+
31
+ Create `_data/picture.yml`, add the following:
32
+
33
+ ```yml
34
+ markup_presets:
35
+ default:
36
+ formats: [webp, original]
37
+ ```
38
+
39
+
40
+ ### Here's a more complete demonstration:
41
+
42
+ [Presets]({{ site.baseurl }}/presets) are named collections of settings, and come in 2 kinds: Media
43
+ Presets are named CSS media queries, and Markup Presets determine the output text and images. You
44
+ choose one with the second [tag parameter]({{ site.baseurl }}/usage), or omit for the `default` (as
45
+ in these examples). They are located in `_data/picture.yml`. Here's an example:
46
+
47
+ ```yml
48
+ media_presets:
49
+ mobile: 'max-width: 600px'
50
+
51
+ markup_presets:
52
+ default:
53
+ widths: [600, 900, 1200]
54
+ formats: [webp, original]
55
+ sizes:
56
+ mobile: 80vw
57
+ size: 500px
58
+ ```
59
+
60
+ Imagemagick can easily crop images to an aspect ratio, though you should **read the whole
61
+ installation guide before using this feature**. With the above preset, if you write this:
62
+
63
+
64
+ {% raw %}
65
+ `{% picture test.jpg 3:2 mobile: test2.jpg 1:1 --alt Alternate Text %}`
66
+ {% endraw %}
67
+
68
+ You'll get something like this:
69
+
70
+ ```html
71
+ <!-- Formatted for readability -->
72
+
73
+ <picture>
74
+ <source
75
+ sizes="(max-width: 600px) 80vw, 600px"
76
+ media="(max-width: 600px)"
77
+ srcset="
78
+ /generated/test2-600-21bb6fGUW.webp 600w,
79
+ /generated/test2-900-21bb6fGUW.webp 900w,
80
+ /generated/test2-1200-21bb6fGUW.webp 1200w
81
+ "
82
+ type="image/webp">
83
+ <source
84
+ sizes="(max-width: 600px) 80vw, 600px"
85
+ srcset="
86
+ /generated/test-600-195f7d192.webp 600w,
87
+ /generated/test-900-195f7d192.webp 900w,
88
+ /generated/test-1200-195f7d192.webp 1200w
89
+ "
90
+ type="image/webp">
91
+ <source
92
+ sizes="(max-width: 600px) 80vw, 600px"
93
+ media="(max-width: 600px)"
94
+ srcset="
95
+ /generated/test2-600-21bb6fGUW.jpg 600w,
96
+ /generated/test2-900-21bb6fGUW.jpg 900w,
97
+ /generated/test2-1200-21bb6fGUW.jpg 1200w
98
+ "
99
+ type="image/jpeg">
100
+ <source
101
+ sizes="(max-width: 600px) 80vw, 600px"
102
+ srcset="
103
+ /generated/test-600-195f7d192.jpg 600w,
104
+ /generated/test-900-195f7d192.jpg 900w,
105
+ /generated/test-1200-195f7d192.jpg 1200w
106
+ "
107
+ type="image/jpeg">
108
+ <img src="/generated/test-800-195f7dGUW.jpg" alt="Alternate Text">
109
+ </picture>
110
+ ```
111
+
112
+ In other words, you have the art direction, format switching, and resolution switching problems
113
+ *solved*, with a one-liner and a nicely readable config file that is 1/3 as long as the output
114
+ markup. Lighthouse is happy, and you don't even need to crop things yourself.
@@ -1,30 +1,45 @@
1
+ ---
2
+ ---
3
+
1
4
  # Installation
2
5
 
3
- 1. Add `jekyll_picture_tag` to your Gemfile in the `:jekyll_plugins` group:
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:
4
17
 
5
- ```ruby
6
- group :jekyll_plugins do
7
- gem 'jekyll_picture_tag'
8
- end
9
- ```
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
+ ```
10
25
 
11
- 2. `bundle install`
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).
12
28
 
13
- 3. Verify you have ImageMagick (Good chance you do) by entering the following into a terminal:
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.
14
32
 
15
- ```
16
- $ convert --version
17
- ```
18
- You should see something like this:
33
+ ## Cropping and Imagemagick
19
34
 
20
- chronos@localhost ~ $ convert --version
21
- Version: ImageMagick 7.0.8-14 Q16 x86_64 2018-10-31 https://imagemagick.org
22
- Copyright: © 1999-2018 ImageMagick Studio LLC
23
- License: https://imagemagick.org/script/license.php
24
- Features: Cipher DPC HDRI OpenMP
25
- Delegates (built-in): bzlib fontconfig freetype jng jp2 jpeg lcms lzma pangocairo png tiff webp xml zlib
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.
26
38
 
27
- **Note webp under delegates.** This is required if you want to generate webp files.
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).
28
44
 
29
- If you get a 'command not found' error, you'll need to install it. Most package managers
30
- know about it, otherwise it can be downloaded [here](https://imagemagick.org/script/download.php).
45
+ Once I work out how to actually do that, I'll add some guidance here.
@@ -1,3 +1,5 @@
1
+ ---
2
+ ---
1
3
  # Migrating from versions < 1.0
2
4
 
3
5
  This document details the changes from previous versions (Everything before 1.0), and how to migrate
@@ -37,7 +39,9 @@ describes how to get your site working with the new version.
37
39
  Previous tag syntax has been extended, but backwards compatibility (and behaviour of previous
38
40
  versions) is maintained.
39
41
 
42
+ {% raw %}
40
43
  `{% picture img.jpg (implicit attributes) --(argument) (explicit attributes) %}`
44
+ {% endraw %}
41
45
 
42
46
  Implicit attributes are the old way. They are specified after the last source image, and before any
43
47
  explicit attributes (if they are included). These attributes are applied to the `<img>` tag, as in
@@ -1,85 +1,91 @@
1
+ ---
2
+ ---
1
3
  # Notes and FAQ
2
4
 
3
- ## Extra {::nomarkdown} tags or mangled HTML?
5
+ * #### Github Pages?
4
6
 
5
- **TLDR up front:** There's a bug involving `<picture>` tags wrapped in `<a>` tags which is not in my
6
- power to fix.
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.
7
10
 
8
- * If you're getting extra `{::nomarkdown}` tags floating around your images, add `nomarkdown: false`
9
- to either the relevant preset or under `picture` in `_config.yml`.
11
+ * #### HTML attributes
10
12
 
11
- * If you're getting mangled HTML when trying to wrap images with anchor tags, add `nomarkdown: true`
12
- to the preset.
13
-
14
- #### What's going on here:
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
15
18
 
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.
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.
20
22
 
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.)
23
+ * ### Git LFS
26
24
 
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.
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
29
 
30
- #### The fix:
31
30
 
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.
31
+ * #### Extra {::nomarkdown} tags or mangled HTML?
36
32
 
37
- You can disable nomarkdown tags globally by setting `nomarkdown: false` under the `picture:` key in
38
- `_config.yml`.
33
+ **TLDR up front:** There's a bug involving `<picture>` tags wrapped in `<a>` tags which is not in my
34
+ power to fix.
39
35
 
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.**
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`.
42
38
 
43
- ## Input checking
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:**
44
43
 
45
- Jekyll Picture Tag is very trusting. It doesn't do much checking of your inputs, and it does not
46
- fail gracefully if you for example pass it a string when it expects an array. It's on the to-do
47
- list, but for now if you get cryptic errors then double-check your settings and tag arguments.
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
48
 
49
- ## Git LFS
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.)
50
54
 
51
- Putting this here because it bit me: If you want to use git LFS, make sure that your hosting
52
- provider makes those images available during the build process. Netlify, for example, does not. You
53
- won't find this out until you have gone through the entire migration process and try to deploy for
54
- the first time.
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.
55
57
 
56
- ## Lazy Loading, and other javascript related tomfoolery
58
+ **The fix:**
57
59
 
58
- Use one of the `data_` output formats and something like
59
- [LazyLoad](https://github.com/verlok/lazyload). The 'lazy' preset in the example config will work.
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.
60
64
 
61
- ## PictureFill
65
+ You can disable nomarkdown tags globally by setting `nomarkdown: false` under the `picture:` key in
66
+ `_config.yml`.
62
67
 
63
- [Picturefill](http://scottjehl.github.io/picturefill/) version 3 no longer requires special markup.
64
- Standard outputs should be compatible.
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.**
65
70
 
66
- ## Managing Generated Images
71
+ * ### Managing Generated Images
67
72
 
68
- Jekyll Picture Tag creates resized versions of your images when you build the site. It uses a smart
69
- caching system to speed up site compilation, and re-uses images as much as possible. Filenames
70
- take the following format:
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:
71
76
 
72
- `(original filename without extension)-(width)-(source hash).(appropriate extension)`
77
+ `(original name without extension)-(width)-(source hash).(filetype)`
73
78
 
74
- Source hash is the first 5 characters of an md5 checksum of the source image.
79
+ Source hash is the first 5 characters of an md5 checksum of the source image.
75
80
 
76
- Try to use a base image that is larger than the largest resized image you need. Jekyll Picture Tag
77
- will warn you if a base image is too small, and won't upscale images.
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.
78
83
 
79
- By specifying a `source` directory that is ignored by Jekyll you can prevent huge base images from
80
- being copied to the compiled site. For example, `source: assets/images/_fullsize` and `output:
81
- generated` will result in a compiled site that contains resized images but not the originals. Note
82
- that this will break source image linking, if you wish to enable it. (Can't link to images that
83
- aren't public!)
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!)
84
89
 
85
- The `output` directory is never deleted by Jekyll. You may want to empty it once in awhile, to clear out unused images.
90
+ The `output` directory is never deleted by Jekyll. You may want to empty it once in awhile, to
91
+ clear out unused images.