jekyll-cloudinary 1.8.1 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b863e9b4acab51ae62dbf96d68b43d059b6aab3
4
- data.tar.gz: 2f6cdda99017506fb2146f67b046ef099e85a040
3
+ metadata.gz: d92d55d6589b7b6b1caec3d8e8e51739d7cec495
4
+ data.tar.gz: 732cc0bbdfc9e8537b82b5e6c76e7a55da7255ec
5
5
  SHA512:
6
- metadata.gz: 7786281d3a9a2cbdc88e092edc8a528aeec9b22cec26394a0e86da19aa1f4845eab5db53265ef1f9c2fe51edcc9f35bf9680a528fba11bdbc502d24b8061c508
7
- data.tar.gz: 760d8da6e314764339e04d2261f0ed9077499d3356a26c477f7f3ae3febf3da2fb62ad8f0e6e3d65976e1ea738fa2d00de469b427638500c0715cd8c4d6dfd90
6
+ metadata.gz: bb0272e18e7afccab31bb8241901416b376712f620d136a5b7671469cbe829e90c2e0bf32f713764b7ecbf14cea301990c946bc829d470870c58685e396b21e4
7
+ data.tar.gz: a506fad8cca0ed024d510808dcecfb0ce086b43bbe38a3a3736f3e6d5a81985417cd90fcec8b571fe2d3f098505b1ad229fb4952fabf60452b15211d53141e7b
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Cloudinary
3
- VERSION = "1.8.1".freeze
3
+ VERSION = "1.9.0".freeze
4
4
  end
5
5
  end
@@ -124,33 +124,6 @@ module Jekyll
124
124
  # image_src.gsub! "url2png:", ""
125
125
  # end
126
126
 
127
- # Build source image URL
128
- is_image_remote = /^https?/.match(image_src)
129
- # It’s remote
130
- if is_image_remote
131
- image_path = image_src
132
- image_url = image_src
133
- # It’s local
134
- else
135
- is_image_path_absolute = %r!^/.*$!.match(image_src)
136
- if is_image_path_absolute
137
- image_path = File.join(site.config["destination"], image_src)
138
- image_url = File.join(url, baseurl, image_src)
139
- else
140
- image_path = File.join(
141
- site.config["destination"],
142
- File.dirname(context["page"]["url"]),
143
- image_src
144
- )
145
- image_url = File.join(
146
- url,
147
- baseurl,
148
- File.dirname(context["page"]["url"]),
149
- image_src
150
- )
151
- end
152
- end
153
-
154
127
  if markup[:preset]
155
128
  if settings["presets"][markup[:preset]]
156
129
  preset = preset.merge(settings["presets"][markup[:preset]])
@@ -216,25 +189,63 @@ module Jekyll
216
189
  transformations_string = transformations.compact.reject(&:empty?).join(',') + ","
217
190
  end
218
191
 
219
- # Get source image natural width
192
+ # Build source image URL
193
+ is_image_remote = /^https?/.match(image_src)
220
194
  if is_image_remote
221
- natural_width, natural_height = FastImage.size(image_url)
195
+ # It’s remote
196
+ image_dest_path = image_src
197
+ image_dest_url = image_src
198
+ natural_width, natural_height = FastImage.size(image_dest_url)
222
199
  width_height = "width=\"#{natural_width}\" height=\"#{natural_height}\""
223
- fallback_url = "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{preset["fallback_max_width"]}/#{image_url}"
200
+ fallback_url = "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{preset["fallback_max_width"]}/#{image_dest_url}"
224
201
  else
225
- if File.exist?(image_path)
226
- natural_width, natural_height = FastImage.size(image_path)
202
+ # It’s a local image
203
+ is_image_src_absolute = %r!^/.*$!.match(image_src)
204
+ if is_image_src_absolute
205
+ image_src_path = File.join(
206
+ site.config["source"],
207
+ image_src
208
+ )
209
+ image_dest_path = File.join(
210
+ site.config["destination"],
211
+ image_src
212
+ )
213
+ image_dest_url = File.join(
214
+ url,
215
+ baseurl,
216
+ image_src
217
+ )
218
+ else
219
+ image_src_path = File.join(
220
+ site.config["source"],
221
+ File.dirname(context["page"]["path"]),
222
+ image_src
223
+ )
224
+ image_dest_path = File.join(
225
+ site.config["destination"],
226
+ File.dirname(context["page"]["url"]),
227
+ image_src
228
+ )
229
+ image_dest_url = File.join(
230
+ url,
231
+ baseurl,
232
+ File.dirname(context["page"]["url"]),
233
+ image_src
234
+ )
235
+ end
236
+ if File.exist?(image_src_path)
237
+ natural_width, natural_height = FastImage.size(image_src_path)
227
238
  width_height = "width=\"#{natural_width}\" height=\"#{natural_height}\""
228
- fallback_url = "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{preset["fallback_max_width"]}/#{image_url}"
239
+ fallback_url = "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{preset["fallback_max_width"]}/#{image_dest_url}"
229
240
  else
230
241
  natural_width = 100_000
231
242
  width_height = ""
232
243
  Jekyll.logger.warn(
233
244
  "[Cloudinary]",
234
- "Couldn't find this image to check its width: #{image_path}. \
245
+ "Couldn't find this image to check its width: #{image_src_path}. \
235
246
  Try to run Jekyll build a second time."
236
247
  )
237
- fallback_url = image_url
248
+ fallback_url = image_dest_url
238
249
  end
239
250
  end
240
251
 
@@ -253,19 +264,19 @@ module Jekyll
253
264
  in #{context["page"]["path"]} not enough for ANY srcset version"
254
265
  )
255
266
  end
256
- srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{natural_width}/#{image_url} #{natural_width}w"
267
+ srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{natural_width}/#{image_dest_url} #{natural_width}w"
257
268
  else
258
269
  missed_sizes = []
259
270
  (1..steps).each do |factor|
260
271
  width = min_width + (factor - 1) * step_width
261
272
  if width <= natural_width
262
- srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{width}/#{image_url} #{width}w"
273
+ srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{width}/#{image_dest_url} #{width}w"
263
274
  else
264
275
  missed_sizes.push(width)
265
276
  end
266
277
  end
267
278
  unless missed_sizes.empty?
268
- srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{natural_width}/#{image_url} #{natural_width}w"
279
+ srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{natural_width}/#{image_dest_url} #{natural_width}w"
269
280
  if settings["verbose"]
270
281
  Jekyll.logger.warn(
271
282
  "[Cloudinary]",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-cloudinary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Hoizey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-03 00:00:00.000000000 Z
11
+ date: 2017-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll