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.
- checksums.yaml +4 -4
- data/lib/jekyll/cloudinary.rb +17 -60
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5152243b460bfb13890cf66737ec1704050f4b3fc0c7868e2344d6b4778cc904
|
4
|
+
data.tar.gz: f0cf14009788f1b27edef724687063d5f33346d4707c13186faab0d06f6a5f5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed624e392464332a228027f318f1c8f5a4e1c5a58f6f8ceb73ca6c9cc4956189af2b50c750b6a26679290721b25437013d0a67b0e5e490ed06aedf973d783de8
|
7
|
+
data.tar.gz: cf6287a77c0e8a02c7a8eaf99f566c028493d8125dbc5644f61215b335be3e1bac2255f861c3e51115bbaa0d8882a9881e1c2c307779aec7c23a12dd383b8d22
|
data/lib/jekyll/cloudinary.rb
CHANGED
@@ -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 = "
|
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 =
|
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
|
-
|
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"]}/#{
|
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
|
-
|
277
|
-
if settings["only_prod"] && ENV["JEKYLL_ENV"] != "production"
|
278
|
-
|
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}/#{
|
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}/#{
|
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}/#{
|
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]",
|