jekyll-cloudinary 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +59 -10
- data/lib/jekyll/cloudinary/version.rb +1 -1
- data/lib/jekyll/cloudinary.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f89661284c40115e8a2eb8bb429141d760f5255b
|
4
|
+
data.tar.gz: b154e81a2d9b3fe2a22083d9d3a2b9cd035da01d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 227e844f37540fa5d33b88b0b83cfaeb2cf2e92b5752a0cd70b907d2f8ee3f23133851dbf7f148634cf8c1b0782d56bdc4a471655c1deef78d6d1e105789d240
|
7
|
+
data.tar.gz: 980cc9a535c8a6508831ac5c9ee70ad33eb2bf49f0b1ad567e67c9530704e5054e195df39e2c6d4e18acfa7bc6ae9ee2c3898d15c8cc77f8b28a1959863ad53e
|
data/README.md
CHANGED
@@ -12,9 +12,9 @@ Here is the general syntax of this Liquid tag:
|
|
12
12
|
{% cloudinary [preset] path/to/img.jpg [attr="value"] %}
|
13
13
|
```
|
14
14
|
|
15
|
-
##
|
15
|
+
## Installation
|
16
16
|
|
17
|
-
[Sign up for free on Cloudinary](http://cloudinary.com/invites/lpov9zyyucivvxsnalc5/sgyyc0j14k6p0sbt51nw). The free account should be enough for
|
17
|
+
[Sign up for free on Cloudinary](http://cloudinary.com/invites/lpov9zyyucivvxsnalc5/sgyyc0j14k6p0sbt51nw). The free account should be enough for most blogs.
|
18
18
|
|
19
19
|
Add `gem 'jekyll-cloudinary'` to your `Gemfile` and run `bundle update` to install the gem.
|
20
20
|
|
@@ -46,8 +46,19 @@ cloudinary:
|
|
46
46
|
verbose: true
|
47
47
|
```
|
48
48
|
|
49
|
-
#### `verbose`
|
49
|
+
#### `verbose` (default: `false`)
|
50
50
|
|
51
|
+
When set to `true`, this setting will show messages in the console when something goes wrong, such as:
|
52
|
+
|
53
|
+
```
|
54
|
+
[Cloudinary] Couldn't find this image to check its width: /path/to/jekyll/_site/assets/img.jpg
|
55
|
+
```
|
56
|
+
|
57
|
+
or
|
58
|
+
|
59
|
+
```
|
60
|
+
[Cloudinary] Natural width of source image 'img.jpg' (720px) in _posts/2016-06-09-post.md not enough for creating 1600px version
|
61
|
+
```
|
51
62
|
|
52
63
|
### Optional (but highly recommended) presets
|
53
64
|
|
@@ -80,10 +91,13 @@ To get this HTML:
|
|
80
91
|
|
81
92
|
|
82
93
|
|
94
|
+
There is a true default default preset, but you're strongly encouraged to define your own default preset.
|
83
95
|
|
84
96
|
#### Additional presets
|
85
97
|
|
86
|
-
You can add other presets if you need several image sizes in your posts
|
98
|
+
You can add other presets if you need several image sizes in your posts.
|
99
|
+
|
100
|
+
Here is an example for images that take only one third of the post width:
|
87
101
|
|
88
102
|
```yaml
|
89
103
|
cloudinary:
|
@@ -96,19 +110,54 @@ cloudinary:
|
|
96
110
|
steps: 3
|
97
111
|
sizes: "(min-width: 50rem) 17rem, 30vw"
|
98
112
|
attributes:
|
99
|
-
class:
|
113
|
+
class: "one3rd"
|
114
|
+
```
|
115
|
+
|
116
|
+
To use this additional preset, you will have to write this in your Markdown post:
|
117
|
+
|
118
|
+
```liquid
|
119
|
+
{% cloudinary onethird /assets/img.jpg %}
|
100
120
|
```
|
101
121
|
|
102
|
-
|
122
|
+
The generated element will also get a `class="one3rd"` that can be useful for example with this CSS:
|
123
|
+
|
124
|
+
```css
|
125
|
+
.one3rd {
|
126
|
+
max-width: 33%;
|
127
|
+
float: right;
|
128
|
+
margin: 0 0 1em 1em;
|
129
|
+
}
|
130
|
+
```
|
131
|
+
|
132
|
+
### Detailed preset settings
|
133
|
+
|
134
|
+
#### `figure` (default: `auto`)
|
135
|
+
|
136
|
+
This setting lets you decide what to do when there is a `caption` attribute in the Cloudinary Liquid tag.
|
137
|
+
|
138
|
+
The value can be:
|
139
|
+
|
140
|
+
- `auto` (default): will generate a `<figure>` and `<figcaption>` only if there's a caption
|
141
|
+
- `never`: will always generate a `<img>`, losing the caption
|
142
|
+
- `always`: will always generate a `<figure>` and `<figcaption>`, even if there's no `caption` attribute
|
143
|
+
|
144
|
+
If a `<figure>` is generated and there are attributes in the Liquid tag, they are added to the `<img>` if they are `alt` or `title`, or to the `<figure>`.
|
145
|
+
|
146
|
+
#### `min_size` (default: `320`)
|
147
|
+
|
148
|
+
#### `max_size` (default: `1200`)
|
149
|
+
|
150
|
+
#### `steps` (default: `5`)
|
103
151
|
|
104
|
-
#### `
|
152
|
+
#### `sizes` (default: `"100vw"`)
|
105
153
|
|
106
|
-
#### `
|
154
|
+
#### `attributes` (default: none)
|
107
155
|
|
108
|
-
|
156
|
+
Attributes are added without transformation to the generated element.
|
109
157
|
|
110
|
-
|
158
|
+
You can obviously define the `alt` attribute, mandatory for accessibility, but you can also set a `title`, a `class`, `aria-*` attributes for enhanced accessibility, or even `data-*` attributes you would like to use later with CSS or JavaScript.
|
111
159
|
|
160
|
+
The `caption` attribute is the only one that can act differently, depending on the `figure` setting.
|
112
161
|
|
113
162
|
## Examples
|
114
163
|
|
data/lib/jekyll/cloudinary.rb
CHANGED
@@ -64,7 +64,7 @@ module Jekyll
|
|
64
64
|
else
|
65
65
|
natural_width = 100000
|
66
66
|
if settings['verbose']
|
67
|
-
puts "\n[Cloudinary]
|
67
|
+
puts "\n[Cloudinary] Couldn't find this image to check its width: #{image_path}"
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -145,8 +145,8 @@ module Jekyll
|
|
145
145
|
end
|
146
146
|
srcset_string = srcset.join(",\n")
|
147
147
|
|
148
|
-
# preset['
|
149
|
-
if (caption || preset['
|
148
|
+
# preset['figure'] can be 'never', 'auto' or 'always'
|
149
|
+
if (caption || preset['figure'] == 'always') && preset['figure'] != 'never'
|
150
150
|
"\n<figure #{attr_string}>\n<img src=\"#{image_url}\" srcset=\"#{srcset_string}\" sizes=\"#{sizes}\" #{img_attr} />\n<figcaption>#{caption}</figcaption>\n</figure>\n"
|
151
151
|
else
|
152
152
|
"<img src=\"#{image_url}\" srcset=\"#{srcset_string}\" sizes=\"#{sizes}\" #{attr_string} #{img_attr} />"
|