jekyll-plugin-cloudinary 1.14.3 → 1.14.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll/cloudinary.rb +17 -60
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bbeeb0360e827069b6757f2072800c1b27c76b70d8b739f35f4c8e5eb765d87
4
- data.tar.gz: ed9a6c144944747216fad276b73eea031f1b8d2aedde07a7abe22867da904f79
3
+ metadata.gz: 5152243b460bfb13890cf66737ec1704050f4b3fc0c7868e2344d6b4778cc904
4
+ data.tar.gz: f0cf14009788f1b27edef724687063d5f33346d4707c13186faab0d06f6a5f5f
5
5
  SHA512:
6
- metadata.gz: 1aae7da8b9b2704625e23e154f2708d8f73f66d6639bc4eeaca86d89ecb64b3c650c8642a00c4a6cc247d19b00663c29eea065a6d143f760e6e6cdf553b254a9
7
- data.tar.gz: ec46383dfac0efb558a31a6849529ee1149e2eb4b2f1d73e613ad1084a7d2768a9f1e7cc1ea16494ef8408844c80ac907b1d4fdd5cb11429718058406094f3e5
6
+ metadata.gz: ed624e392464332a228027f318f1c8f5a4e1c5a58f6f8ceb73ca6c9cc4956189af2b50c750b6a26679290721b25437013d0a67b0e5e490ed06aedf973d783de8
7
+ data.tar.gz: cf6287a77c0e8a02c7a8eaf99f566c028493d8125dbc5644f61215b335be3e1bac2255f861c3e51115bbaa0d8882a9881e1c2c307779aec7c23a12dd383b8d22
@@ -127,15 +127,16 @@ module Jekyll
127
127
  Jekyll.logger.abort_with("[Cloudinary]", "Can't read this tag: #{@markup}")
128
128
  end
129
129
 
130
- image_src = markup[:image_src]
131
-
132
130
  # Dynamic image type
133
- type = "fetch"
131
+ type = "upload"
134
132
  # TODO: URL2PNG requires signed URLs... need to investigate more
135
133
  # if /^url2png\:/.match(image_src)
136
134
  # type = "url2png"
137
135
  # image_src.gsub! "url2png:", ""
138
136
  # end
137
+ # More TODO: GK changed from fetch
138
+
139
+ image_src = markup[:image_src]
139
140
 
140
141
  if markup[:preset]
141
142
  if settings["presets"][markup[:preset]]
@@ -207,11 +208,13 @@ module Jekyll
207
208
  end
208
209
 
209
210
  # Build source image URL
210
- is_image_remote = %r!^https?!.match(image_src)
211
+ is_image_remote = true #%r!^https?!.match(image_src)
211
212
  if is_image_remote
212
213
  # It's remote
213
214
  image_dest_path = image_src
214
- image_dest_url = image_src
215
+ #image_dest_url = image_src
216
+ image_dest_url = "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/q_auto:best/#{image_src}"
217
+
215
218
  if ENV["JEKYLL_ENV"] != "production"
216
219
  natural_width, natural_height = nil
217
220
  else
@@ -221,62 +224,16 @@ module Jekyll
221
224
  if ENV["JEKYLL_ENV"] == "production"
222
225
  Jekyll.logger.warn("remote url doesn't exists " + image_dest_url)
223
226
  end
224
- return "<img src=\"#{image_dest_url}\" />"
227
+ return "<img src=\"#{image_dest_url}\" />"
225
228
  end
226
229
  width_height = "width=\"#{natural_width}\" height=\"#{natural_height}\""
227
- fallback_url = "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{preset["fallback_max_width"]}/#{image_dest_url}"
228
- else
229
- # It's a local image
230
- is_image_src_absolute = %r!^/.*$!.match(image_src)
231
- if is_image_src_absolute
232
- image_src_path = File.join(
233
- site.config["source"],
234
- image_src
235
- )
236
- image_dest_path = File.join(
237
- site.config["destination"],
238
- image_src
239
- )
240
- image_dest_url = File.join(
241
- url,
242
- image_src
243
- )
244
- else
245
- image_src_path = File.join(
246
- site.config["source"],
247
- File.dirname(context["page"]["path"].chomp("/#excerpt")),
248
- image_src
249
- )
250
- image_dest_path = File.join(
251
- site.config["destination"],
252
- File.dirname(context["page"]["url"]),
253
- image_src
254
- )
255
- image_dest_url = File.join(
256
- url,
257
- File.dirname(context["page"]["url"]),
258
- image_src
259
- )
260
- end
261
- if File.exist?(image_src_path)
262
- natural_width, natural_height = FastImage.size(image_src_path)
263
- width_height = "width=\"#{natural_width}\" height=\"#{natural_height}\""
264
- fallback_url = "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{preset["fallback_max_width"]}/#{image_dest_url}"
265
- else
266
- natural_width = 100_000
267
- width_height = ""
268
- Jekyll.logger.warn(
269
- "[Cloudinary]",
270
- "Couldn't find this image to check its width: #{image_src_path}."
271
- )
272
- fallback_url = image_dest_url
273
- end
230
+ fallback_url = "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{preset["fallback_max_width"]}/#{image_src}"
274
231
  end
275
232
 
276
- # Don't generate responsive image HTML and Cloudinary URLs for local development
277
- if settings["only_prod"] && ENV["JEKYLL_ENV"] != "production"
278
- return "<img src=\"#{image_dest_url}\" #{attr_string} #{img_attr} #{width_height} crossorigin=\"anonymous\" />"
279
- end
233
+ ## Don't generate responsive image HTML and Cloudinary URLs for local development
234
+ #if settings["only_prod"] && ENV["JEKYLL_ENV"] != "production"
235
+ # return "<img src=\"#{image_dest_url}\" #{attr_string} #{img_attr} #{width_height} crossorigin=\"anonymous\" />"
236
+ #end
280
237
 
281
238
  srcset = []
282
239
  steps = preset["steps"].to_i
@@ -293,19 +250,19 @@ module Jekyll
293
250
  in #{context["page"]["path"]} not enough for ANY srcset version"
294
251
  )
295
252
  end
296
- srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{natural_width}/#{image_dest_url} #{natural_width}w"
253
+ srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{natural_width}/#{image_src} #{natural_width}w"
297
254
  else
298
255
  missed_sizes = []
299
256
  (1..steps).each do |factor|
300
257
  width = min_width + (factor - 1) * step_width
301
258
  if width <= natural_width
302
- srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{width}/#{image_dest_url} #{width}w"
259
+ srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{width}/#{image_src} #{width}w"
303
260
  else
304
261
  missed_sizes.push(width)
305
262
  end
306
263
  end
307
264
  unless missed_sizes.empty?
308
- srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{natural_width}/#{image_dest_url} #{natural_width}w"
265
+ srcset << "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{natural_width}/#{image_src} #{natural_width}w"
309
266
  if settings["verbose"]
310
267
  Jekyll.logger.warn(
311
268
  "[Cloudinary]",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-plugin-cloudinary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.3
4
+ version: 1.14.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@glueckkanja"