jekyll_picture_tag 1.9.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.travis.yml +4 -7
  4. data/Dockerfile +9 -0
  5. data/docs/Gemfile +4 -2
  6. data/docs/Gemfile.lock +186 -89
  7. data/docs/_config.yml +6 -10
  8. data/docs/devs/contributing/code.md +44 -0
  9. data/docs/devs/contributing/docs.md +13 -0
  10. data/docs/devs/contributing/index.md +15 -0
  11. data/docs/devs/contributing/setup.md +13 -0
  12. data/docs/devs/contributing/testing.md +41 -0
  13. data/docs/devs/index.md +7 -0
  14. data/docs/{releases.md → devs/releases.md} +35 -13
  15. data/docs/index.md +58 -36
  16. data/docs/users/configuration/cdn.md +35 -0
  17. data/docs/users/configuration/directories.md +34 -0
  18. data/docs/users/configuration/disable.md +24 -0
  19. data/docs/users/configuration/fast_build.md +28 -0
  20. data/docs/users/configuration/ignore_missing.md +23 -0
  21. data/docs/users/configuration/index.md +29 -0
  22. data/docs/users/configuration/kramdown_fix.md +20 -0
  23. data/docs/users/configuration/relative_urls.md +15 -0
  24. data/docs/users/configuration/suppress_warnings.md +16 -0
  25. data/docs/users/index.md +7 -0
  26. data/docs/users/installation.md +52 -0
  27. data/docs/users/liquid_tag/argument_reference/alternate_images.md +18 -0
  28. data/docs/users/liquid_tag/argument_reference/attributes.md +42 -0
  29. data/docs/users/liquid_tag/argument_reference/base_image.md +12 -0
  30. data/docs/users/liquid_tag/argument_reference/crop.md +48 -0
  31. data/docs/users/liquid_tag/argument_reference/link.md +16 -0
  32. data/docs/users/liquid_tag/argument_reference/preset.md +17 -0
  33. data/docs/users/liquid_tag/argument_reference/readme.md +9 -0
  34. data/docs/users/liquid_tag/examples.md +81 -0
  35. data/docs/users/liquid_tag/index.md +31 -0
  36. data/docs/users/notes/git_lfs.md +7 -0
  37. data/docs/users/notes/github_pages.md +5 -0
  38. data/docs/users/notes/html_attributes.md +5 -0
  39. data/docs/users/notes/index.md +6 -0
  40. data/docs/users/notes/input_checking.md +6 -0
  41. data/docs/users/notes/kramdown_bug.md +41 -0
  42. data/docs/users/notes/managing_images.md +21 -0
  43. data/docs/{migration.md → users/notes/migration.md} +0 -0
  44. data/docs/users/presets/cropping.md +61 -0
  45. data/docs/users/presets/default.md +23 -0
  46. data/docs/users/presets/examples.md +79 -0
  47. data/docs/users/presets/fallback_image.md +28 -0
  48. data/docs/users/presets/html_attributes.md +26 -0
  49. data/docs/users/presets/image_formats.md +21 -0
  50. data/docs/users/presets/image_quality.md +43 -0
  51. data/docs/users/presets/index.md +101 -0
  52. data/docs/users/presets/link_source.md +16 -0
  53. data/docs/users/presets/markup_formats/fragments.md +48 -0
  54. data/docs/users/presets/markup_formats/javascript_friendly.md +57 -0
  55. data/docs/users/presets/markup_formats/readme.md +43 -0
  56. data/docs/users/presets/markup_formats/standard_html.md +25 -0
  57. data/docs/users/presets/media_queries.md +36 -0
  58. data/docs/users/presets/nomarkdown_override.md +17 -0
  59. data/docs/users/presets/pixel_ratio_srcsets.md +32 -0
  60. data/docs/users/presets/width_height_attributes.md +34 -0
  61. data/docs/users/presets/width_srcsets.md +85 -0
  62. data/jekyll_picture_tag.gemspec +1 -1
  63. data/lib/jekyll_picture_tag.rb +1 -0
  64. data/lib/jekyll_picture_tag/cache.rb +3 -0
  65. data/lib/jekyll_picture_tag/cache/base.rb +59 -0
  66. data/lib/jekyll_picture_tag/cache/generated.rb +20 -0
  67. data/lib/jekyll_picture_tag/cache/source.rb +19 -0
  68. data/lib/jekyll_picture_tag/defaults/presets.yml +2 -0
  69. data/lib/jekyll_picture_tag/generated_image.rb +52 -41
  70. data/lib/jekyll_picture_tag/img_uri.rb +1 -0
  71. data/lib/jekyll_picture_tag/instructions.rb +1 -0
  72. data/lib/jekyll_picture_tag/instructions/arg_splitter.rb +69 -0
  73. data/lib/jekyll_picture_tag/instructions/configuration.rb +1 -1
  74. data/lib/jekyll_picture_tag/instructions/preset.rb +40 -15
  75. data/lib/jekyll_picture_tag/instructions/set.rb +23 -9
  76. data/lib/jekyll_picture_tag/instructions/tag_parser.rb +59 -69
  77. data/lib/jekyll_picture_tag/output_formats/basic.rb +34 -15
  78. data/lib/jekyll_picture_tag/output_formats/img.rb +11 -0
  79. data/lib/jekyll_picture_tag/output_formats/picture.rb +22 -0
  80. data/lib/jekyll_picture_tag/router.rb +9 -0
  81. data/lib/jekyll_picture_tag/source_image.rb +60 -44
  82. data/lib/jekyll_picture_tag/srcsets/basic.rb +29 -7
  83. data/lib/jekyll_picture_tag/utils.rb +18 -0
  84. data/lib/jekyll_picture_tag/version.rb +1 -1
  85. data/readme.md +40 -16
  86. metadata +67 -20
  87. data/docs/_layouts/directory.html +0 -32
  88. data/docs/assets/style.css +0 -31
  89. data/docs/contributing.md +0 -75
  90. data/docs/example_presets.md +0 -116
  91. data/docs/global_configuration.md +0 -173
  92. data/docs/installation.md +0 -30
  93. data/docs/notes.md +0 -91
  94. data/docs/output.md +0 -63
  95. data/docs/presets.md +0 -309
  96. data/docs/usage.md +0 -113
@@ -0,0 +1,23 @@
1
+ ---
2
+ sort: 3
3
+ ---
4
+
5
+ # Ignore Missing Source Images
6
+
7
+ *Format:* `ignore_missing_images: (boolean|environment|environments)`
8
+
9
+ *Examples:*
10
+ - `ignore_missing_images: true`
11
+ - `ignore_missing_images: development`
12
+ - `ignore_missing_images: [development, testing]`
13
+
14
+ *Default:* `false`
15
+
16
+ Normally, JPT will raise an error if a source image is missing, causing the
17
+ entire site build to fail. This setting allows you to bypass this behavior and
18
+ continue the build, either for certain build environments or all the time.
19
+
20
+ I highly encourage you to set this to `development`, and set the Jekyll build
21
+ environment to `production` when you build for production so you don't shoot
22
+ yourself in the foot. You can read more about Jekyll environments
23
+ [here](https://jekyllrb.com/docs/configuration/environments/).
@@ -0,0 +1,29 @@
1
+ ---
2
+ sort: 1
3
+ ---
4
+ # Global Configuration
5
+
6
+ **All configuration is optional**. If you are happy with the defaults, you don't
7
+ have to touch a single yml file.
8
+
9
+ Global settings are stored under the `picture:` key in `/_config.yml`.
10
+
11
+ **Example:**
12
+
13
+ ```yml
14
+ # _config.yml
15
+
16
+ (...)
17
+
18
+ picture:
19
+ source: "assets/images/fullsize"
20
+ output: "assets/images/generated"
21
+ suppress_warnings: true
22
+ (...)
23
+
24
+ (...)
25
+ ```
26
+
27
+ ## Reference
28
+
29
+ {% include list.liquid %}
@@ -0,0 +1,20 @@
1
+ ---
2
+ sort: 8
3
+ ---
4
+
5
+ # Kramdown Fix
6
+
7
+ *Format:* `nomarkdown: (true|false)`
8
+
9
+ *Example:* `nomarkdown: false`
10
+
11
+ *Default:* `true`
12
+
13
+ Whether or not to surround j-p-t's output with a
14
+ `{::nomarkdown}..{:/nomarkdown}` block when called from within a markdown file.
15
+ When false, JPT will never add the wrapper. When true, JPT will add it only when
16
+ it believes it's necessary, though it's not 100% accurate at making this
17
+ determination.
18
+
19
+ This setting is overridden by the same setting in a preset. See [this note]({{
20
+ site.baseurl }}/users/notes/kramdown_bug) for more detailed information.
@@ -0,0 +1,15 @@
1
+ ---
2
+ sort: 6
3
+ ---
4
+
5
+ # Use Relative Urls
6
+
7
+ *Format:* `relative_url: (true|false)`
8
+
9
+ *Example:* `relative_url: false`
10
+
11
+ *Default*: `true`
12
+
13
+ Whether to use relative (`/generated/test(...).jpg`) or absolute
14
+ (`https://example.com/generated/test(...).jpg`) urls in your src and srcset
15
+ attributes.
@@ -0,0 +1,16 @@
1
+ ---
2
+ sort: 2
3
+ ---
4
+
5
+ # Suppress Warnings
6
+
7
+ *Format:* `suppress_warnings: (true|false)`
8
+
9
+ *Example:* `suppress_warnings: true`
10
+
11
+ *Default*: `false`
12
+
13
+ Jekyll Picture Tag will warn you in a few different scenarios, such as when your
14
+ base image is smaller than one of the sizes in your preset. (Note that Jekyll
15
+ Picture Tag will never resize an image to be larger than its source). Set this
16
+ value to `true`, and these warnings will not be shown.
@@ -0,0 +1,7 @@
1
+ ---
2
+ sort: 1
3
+ ---
4
+
5
+ # Usage
6
+
7
+ {% include list.liquid %}
@@ -0,0 +1,52 @@
1
+ ---
2
+ ---
3
+
4
+ # Installation
5
+
6
+ 1. Add `jekyll_picture_tag` to your Gemfile in the `:jekyll_plugins` group.
7
+ (Note that it's NOT `jekyll-picture-tag`):
8
+ ```ruby
9
+ # Gemfile
10
+
11
+ gem 'jekyll'
12
+
13
+ group :jekyll_plugins do
14
+ gem 'jekyll_picture_tag', ~> '1'
15
+ end
16
+ ```
17
+ 2. Run `$ bundle install`
18
+ 3. See if you have ImageMagick with `$ convert --version`. You should see
19
+ something like this:
20
+ ```bash
21
+ ~ $ convert --version
22
+ Version: ImageMagick 7.0.8-14 Q16 x86_64 2018-10-31 https://imagemagick.org
23
+ Copyright: © 1999-2018 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php
24
+ Features: Cipher DPC HDRI OpenMP Delegates (built-in): bzlib fontconfig freetype jng jp2 jpeg lcms
25
+ lzma pangocairo png tiff webp xml zlib
26
+ ```
27
+ If you get a 'command not found' error, you'll need to install it. Most
28
+ package managers know about ImageMagick, otherwise it can be found
29
+ [here](https://imagemagick.org/script/download.php).
30
+
31
+ ```note
32
+ You need a 'webp' delegate if you want to generate webp files. Any image
33
+ format you want to handle will require an appropriate delegate; You may have
34
+ to install additional packages to accomplish this. Usually it's just named
35
+ 'webp'.
36
+ ```
37
+
38
+ ```warning
39
+ Cropping to an aspect ratio depends on ImageMagick 7+. Ubuntu, somewhat
40
+ annoyingly, only offers version 6 in its official repositories. This matters
41
+ even if you don't run Ubuntu, because many build & deployment services you might
42
+ use (including Netlify and Travis CI) do.
43
+ ```
44
+
45
+ If you'd like to use both the cropping feature and such a service, or it's
46
+ inconvenient to install version 7 in your development environment, you will
47
+ likely want to build your site in a docker container. The Alpine Linux repos
48
+ include version 7, so you'll want an Alpine Linux based image rather than an
49
+ Ubuntu based one. Conveniently this includes the [offical Jekyll
50
+ image](https://hub.docker.com/r/jekyll/jekyll).
51
+
52
+ Once I work out how to actually do that, I'll add some guidance here.
@@ -0,0 +1,18 @@
1
+ ---
2
+ sort: 4
3
+ ---
4
+
5
+ # Alternate images
6
+
7
+ _Format:_ `(media_query): (filename) [crop] [gravity] (...)`
8
+
9
+ _Example:_ `tablet: img_cropped.jpg mobile: img_cropped_more.jpg`
10
+
11
+ Optionally specify any number of alternate base images for given
12
+ [media_queries]({{ site.baseurl }}/users/presets/media_queries). This is called
13
+ [art direction](http://usecases.responsiveimages.org/#art-direction), and is one
14
+ of JPT's strongest features.
15
+
16
+ Give your images in order of ascending specificity (The first image is the
17
+ most general). They will be provided to the browser in reverse order, and it
18
+ will select the first one with an applicable media query.
@@ -0,0 +1,42 @@
1
+ ---
2
+ sort: 6
3
+ ---
4
+
5
+ # Attributes
6
+
7
+ Optionally specify any number of HTML attributes. These will be combined with
8
+ any which you've set in a preset.
9
+
10
+ All arguments which begin with `--` (including `--link`) must be at the end of
11
+ the liquid tag, but they can be given in any order.
12
+
13
+ - **`--alt`**
14
+
15
+ _Format:_ `--alt (alt text)`
16
+
17
+ _Example:_ `--alt Here is my alt text!`
18
+
19
+ Convenience shortcut for `--img alt="..."`
20
+
21
+ - **`--(element)`**
22
+
23
+ _Format:_ `--(picture|img|source|a|parent) (Standard HTML attributes)`
24
+
25
+ _Example:_ `--img class="awesome-fade-in" id="coolio" --a data-awesomeness="11"`
26
+
27
+ Apply attributes to a given HTML element. Your options are:
28
+
29
+ - `--picture`
30
+ - `--img`
31
+ - `--source`
32
+ - `--a` (anchor tag)
33
+ - `--parent`
34
+
35
+ `--parent` will be applied to the `<picture>` if present, otherwise the
36
+ `<img>`; useful when using an `auto` output format.
37
+
38
+ ```note
39
+ Attributes that are set here for elements which don't occur in the selected
40
+ markup format will be ignored (e.g. adding `--picture class="cool-css"` with a
41
+ preset that does not use a `<picture>` tag).
42
+ ```
@@ -0,0 +1,12 @@
1
+ ---
2
+ sort: 2
3
+ ---
4
+
5
+ # Base Image (Required)
6
+
7
+ Can be any raster image (as long as you have the required ImageMagick delegate).
8
+ Relative to Jekyll's root directory, or the `source` [setting]({{ site.baseurl
9
+ }}/users/configuration/directories) if you've configured it.
10
+
11
+ For filenames with spaces, either use double quotes (`"my image.jpg"`) or a
12
+ backslash (`my\ image.jpg`).
@@ -0,0 +1,48 @@
1
+ ---
2
+ sort: 3
3
+ ---
4
+
5
+ # Crop
6
+
7
+ ```warning
8
+ Ensure that both your development and production build environments have
9
+ ImageMagick 7+ installed before using this feature. Anything based on Ubuntu
10
+ likely does not. The installation guide has more information.
11
+ ```
12
+
13
+ Crop an image to a given aspect ratio or size. This argument is given as a
14
+ `geometry` and (optionally) a `gravity`, which can appear in either order and
15
+ are thin wrappers around ImageMagick's
16
+ [geometry](http://www.imagemagick.org/script/command-line-processing.php#geometry)
17
+ and
18
+ [gravity](http://www.imagemagick.org/script/command-line-options.php#gravity)
19
+ settings. The values given here will override the preset settings (if present),
20
+ can be given after every image, and apply only to the preceding image.
21
+
22
+ Geometry can take many forms, but most likely you'll want to set an aspect
23
+ ratio-- given in the standard `width:height` ratio such as `3:2`. Gravity sets
24
+ which portion of the image to keep, and is given in compass directions (`north`,
25
+ `southeast`, etc) or `center` (default). Cropping happens before resizing; the
26
+ preset `widths` setting is a post-crop value.
27
+
28
+ If you'd like more fine-grained control, this can be offset by appending `+|-x`
29
+ and (optionally) `y` pixel values to the _geometry_ (not the gravity!). Example:
30
+ `1:1+400 west` means "Crop to a 1:1 aspect ratio, starting 400 pixels from the
31
+ left side.", and `north 3:2+0+100` means "Crop to 3:2, starting 100 pixels from
32
+ the top." These can get a bit persnickety; there's nothing to stop you from
33
+ running off the side of the image. Pay attention.
34
+
35
+ For detailed documentation, see ImageMagick's
36
+ [crop](http://www.imagemagick.org/script/command-line-options.php#crop) tool.
37
+
38
+ ## Examples
39
+
40
+ - `16:9`
41
+ - `1:1 west`
42
+ - `3:2+20+50 northeast`
43
+
44
+ ```note
45
+ If you do a lot of trial and error with these, it's a good idea to manually
46
+ delete your generated images folder more often as each change will build a new
47
+ set of images without removing the old ones.
48
+ ```
@@ -0,0 +1,16 @@
1
+ ---
2
+ sort: 5
3
+ ---
4
+
5
+ # Link
6
+
7
+ _Format:_ `--link (some url)`
8
+
9
+ _Examples_: `--link https://example.com`, `--link /blog/some_post/`
10
+
11
+ Wrap the image in an anchor tag, with the `href` attribute set to whatever
12
+ value you give it. This will override automatic source image linking, if you
13
+ have enabled it.
14
+
15
+ **Note**: If you get either mangled HTML or extra {::nomarkdown} tags when
16
+ using this, read [here]({{ site.baseurl }}/users/notes/kramdown_bug).
@@ -0,0 +1,17 @@
1
+ ---
2
+ sort: 1
3
+ ---
4
+
5
+ # Preset
6
+
7
+ Select a [preset]({{ site.baseurl }}/users/presets), or omit to
8
+ use the `default` preset. A preset is a collection of settings which determines
9
+ nearly everything about JPT's output, from the image formats used to the exact
10
+ format your final HTML will take. Think of it like a recipe or a blueprint; JPT
11
+ will take the information provided in the liquid tag, combine it with the
12
+ settings written in the preset, and use it to craft your images and markup.
13
+
14
+ If the `preset` is omitted then default settings will be used, in the simplest
15
+ case resulting in an `<img>` tag containing a srcset pointing to your newly
16
+ generated images. You are free to override the `default` preset and define
17
+ your own settings, giving full flexibility in what JPT will create.
@@ -0,0 +1,9 @@
1
+ ---
2
+ sort: 3
3
+ ---
4
+
5
+ # Argument Reference
6
+
7
+ Given in order:
8
+
9
+ {% include list.liquid %}
@@ -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.