next-cloudinary 1.12.2 → 2.0.0
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.
- package/dist/next-cloudinary.js +69 -946
- package/dist/next-cloudinary.js.map +1 -1
- package/dist/next-cloudinary.modern.mjs +58 -951
- package/dist/next-cloudinary.modern.mjs.map +1 -1
- package/dist/next-cloudinary.module.js +65 -937
- package/dist/next-cloudinary.module.js.map +1 -1
- package/dist/next-cloudinary.umd.js +71 -949
- package/dist/next-cloudinary.umd.js.map +1 -1
- package/package.json +3 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState, useRef } from 'react';
|
|
2
2
|
import Image from 'next/image';
|
|
3
|
-
import {
|
|
3
|
+
import { getPublicId, getTransformations } from '@cloudinary-util/util';
|
|
4
|
+
import { constructCloudinaryUrl, transformationPlugins } from '@cloudinary-util/url-loader';
|
|
4
5
|
import nextPkg from 'next/package.json';
|
|
5
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
7
|
import Head from 'next/head';
|
|
@@ -33,846 +34,8 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
33
34
|
return target;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
var cropsGravityAuto = ['crop', 'fill', 'lfill', 'fill_pad', 'thumb'];
|
|
37
|
-
var cropsWithZoom = ['crop', 'thumb'];
|
|
38
|
-
var props$7 = ['crop', 'gravity', 'zoom'];
|
|
39
|
-
function plugin$7(_temp) {
|
|
40
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
41
|
-
cldImage = _ref.cldImage,
|
|
42
|
-
options = _ref.options;
|
|
43
|
-
var overrides = {};
|
|
44
|
-
var width = options.width,
|
|
45
|
-
height = options.height,
|
|
46
|
-
widthResize = options.widthResize,
|
|
47
|
-
_options$crop = options.crop,
|
|
48
|
-
crop = _options$crop === void 0 ? 'limit' : _options$crop;
|
|
49
|
-
var transformationString = "c_" + crop + ",w_" + width;
|
|
50
|
-
if (!options.gravity && cropsGravityAuto.includes(crop)) {
|
|
51
|
-
options.gravity = 'auto';
|
|
52
|
-
}
|
|
53
|
-
if (!['limit'].includes(crop)) {
|
|
54
|
-
transformationString = transformationString + ",h_" + height;
|
|
55
|
-
}
|
|
56
|
-
if (options.gravity) {
|
|
57
|
-
if (options.gravity === 'auto' && !cropsGravityAuto.includes(crop)) {
|
|
58
|
-
console.warn("Auto gravity can only be used with crop modes: " + cropsGravityAuto.join(', ') + ". Not applying gravity.");
|
|
59
|
-
} else {
|
|
60
|
-
transformationString = transformationString + ",g_" + options.gravity;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (options.zoom) {
|
|
64
|
-
if (options.zoom === 'auto' && !cropsWithZoom.includes(crop)) {
|
|
65
|
-
console.warn("Zoom can only be used with crop modes: " + cropsWithZoom.join(', ') + ". Not applying zoom.");
|
|
66
|
-
} else {
|
|
67
|
-
transformationString = transformationString + ",z_" + options.zoom;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
cldImage.effect(transformationString);
|
|
71
|
-
|
|
72
|
-
// If we have a resize width that's smaller than the user-defined width, we want to give the
|
|
73
|
-
// ability to perform a final resize on the image without impacting any of the effects like text
|
|
74
|
-
// overlays that may depend on the size to work properly
|
|
75
|
-
|
|
76
|
-
if (typeof widthResize === 'number' && widthResize < width) {
|
|
77
|
-
overrides.width = widthResize;
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
options: overrides
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
var croppingPlugin = {
|
|
85
|
-
__proto__: null,
|
|
86
|
-
props: props$7,
|
|
87
|
-
plugin: plugin$7
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// aspectRatio
|
|
91
|
-
|
|
92
|
-
var primary = {
|
|
93
|
-
aspectRatio: {
|
|
94
|
-
qualifier: 'ar'
|
|
95
|
-
},
|
|
96
|
-
crop: {
|
|
97
|
-
qualifier: 'c'
|
|
98
|
-
},
|
|
99
|
-
gravity: {
|
|
100
|
-
qualifier: 'g'
|
|
101
|
-
},
|
|
102
|
-
height: {
|
|
103
|
-
qualifier: 'h'
|
|
104
|
-
},
|
|
105
|
-
width: {
|
|
106
|
-
qualifier: 'w'
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var position = {
|
|
110
|
-
angle: {
|
|
111
|
-
qualifier: 'a'
|
|
112
|
-
},
|
|
113
|
-
gravity: {
|
|
114
|
-
qualifier: 'g'
|
|
115
|
-
},
|
|
116
|
-
x: {
|
|
117
|
-
qualifier: 'x'
|
|
118
|
-
},
|
|
119
|
-
y: {
|
|
120
|
-
qualifier: 'y'
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
var text = {
|
|
124
|
-
alignment: {
|
|
125
|
-
qualifier: 'alignment'
|
|
126
|
-
},
|
|
127
|
-
border: {
|
|
128
|
-
qualifier: 'bo',
|
|
129
|
-
location: 'primary'
|
|
130
|
-
},
|
|
131
|
-
color: {
|
|
132
|
-
qualifier: 'co',
|
|
133
|
-
location: 'primary'
|
|
134
|
-
},
|
|
135
|
-
fontFamily: {
|
|
136
|
-
qualifier: false
|
|
137
|
-
},
|
|
138
|
-
fontSize: {
|
|
139
|
-
qualifier: false
|
|
140
|
-
},
|
|
141
|
-
fontWeight: {
|
|
142
|
-
qualifier: false
|
|
143
|
-
},
|
|
144
|
-
letterSpacing: {
|
|
145
|
-
qualifier: 'letter_spacing'
|
|
146
|
-
},
|
|
147
|
-
lineSpacing: {
|
|
148
|
-
qualifier: 'line_spacing'
|
|
149
|
-
},
|
|
150
|
-
stroke: {
|
|
151
|
-
qualifier: 'self'
|
|
152
|
-
},
|
|
153
|
-
textDecoration: {
|
|
154
|
-
qualifier: false
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
var effects = {
|
|
158
|
-
art: {
|
|
159
|
-
prefix: 'e',
|
|
160
|
-
qualifier: 'art'
|
|
161
|
-
},
|
|
162
|
-
autoBrightness: {
|
|
163
|
-
prefix: 'e',
|
|
164
|
-
qualifier: 'auto_brightness'
|
|
165
|
-
},
|
|
166
|
-
autoColor: {
|
|
167
|
-
prefix: 'e',
|
|
168
|
-
qualifier: 'auto_color'
|
|
169
|
-
},
|
|
170
|
-
autoContrast: {
|
|
171
|
-
prefix: 'e',
|
|
172
|
-
qualifier: 'auto_contrast'
|
|
173
|
-
},
|
|
174
|
-
assistColorblind: {
|
|
175
|
-
prefix: 'e',
|
|
176
|
-
qualifier: 'assist_colorblind'
|
|
177
|
-
},
|
|
178
|
-
background: {
|
|
179
|
-
qualifier: 'b'
|
|
180
|
-
},
|
|
181
|
-
blackwhite: {
|
|
182
|
-
prefix: 'e',
|
|
183
|
-
qualifier: 'blackwhite'
|
|
184
|
-
},
|
|
185
|
-
blur: {
|
|
186
|
-
prefix: 'e',
|
|
187
|
-
qualifier: 'blur'
|
|
188
|
-
},
|
|
189
|
-
blurFaces: {
|
|
190
|
-
prefix: 'e',
|
|
191
|
-
qualifier: 'blur_faces'
|
|
192
|
-
},
|
|
193
|
-
blurRegion: {
|
|
194
|
-
prefix: 'e',
|
|
195
|
-
qualifier: 'blur_region'
|
|
196
|
-
},
|
|
197
|
-
border: {
|
|
198
|
-
qualifier: 'bo'
|
|
199
|
-
},
|
|
200
|
-
brightness: {
|
|
201
|
-
prefix: 'e',
|
|
202
|
-
qualifier: 'brightness'
|
|
203
|
-
},
|
|
204
|
-
brightnessHSB: {
|
|
205
|
-
prefix: 'e',
|
|
206
|
-
qualifier: 'brightness_hsb'
|
|
207
|
-
},
|
|
208
|
-
cartoonify: {
|
|
209
|
-
prefix: 'e',
|
|
210
|
-
qualifier: 'cartoonify'
|
|
211
|
-
},
|
|
212
|
-
color: {
|
|
213
|
-
qualifier: 'co'
|
|
214
|
-
},
|
|
215
|
-
colorize: {
|
|
216
|
-
prefix: 'e',
|
|
217
|
-
qualifier: 'colorize'
|
|
218
|
-
},
|
|
219
|
-
contrast: {
|
|
220
|
-
prefix: 'e',
|
|
221
|
-
qualifier: 'contrast'
|
|
222
|
-
},
|
|
223
|
-
distort: {
|
|
224
|
-
prefix: 'e',
|
|
225
|
-
qualifier: 'distort'
|
|
226
|
-
},
|
|
227
|
-
fillLight: {
|
|
228
|
-
prefix: 'e',
|
|
229
|
-
qualifier: 'fill_light'
|
|
230
|
-
},
|
|
231
|
-
gamma: {
|
|
232
|
-
prefix: 'e',
|
|
233
|
-
qualifier: 'gamma'
|
|
234
|
-
},
|
|
235
|
-
gradientFade: {
|
|
236
|
-
prefix: 'e',
|
|
237
|
-
qualifier: 'gradient_fade'
|
|
238
|
-
},
|
|
239
|
-
grayscale: {
|
|
240
|
-
prefix: 'e',
|
|
241
|
-
qualifier: 'grayscale'
|
|
242
|
-
},
|
|
243
|
-
improve: {
|
|
244
|
-
prefix: 'e',
|
|
245
|
-
qualifier: 'improve'
|
|
246
|
-
},
|
|
247
|
-
multiply: {
|
|
248
|
-
prefix: 'e',
|
|
249
|
-
qualifier: 'multiply'
|
|
250
|
-
},
|
|
251
|
-
negate: {
|
|
252
|
-
prefix: 'e',
|
|
253
|
-
qualifier: 'negate'
|
|
254
|
-
},
|
|
255
|
-
oilPaint: {
|
|
256
|
-
prefix: 'e',
|
|
257
|
-
qualifier: 'oil_paint'
|
|
258
|
-
},
|
|
259
|
-
opacity: {
|
|
260
|
-
qualifier: 'o'
|
|
261
|
-
},
|
|
262
|
-
outline: {
|
|
263
|
-
prefix: 'e',
|
|
264
|
-
qualifier: 'outline'
|
|
265
|
-
},
|
|
266
|
-
overlay: {
|
|
267
|
-
prefix: 'e',
|
|
268
|
-
qualifier: 'overlay'
|
|
269
|
-
},
|
|
270
|
-
pixelate: {
|
|
271
|
-
prefix: 'e',
|
|
272
|
-
qualifier: 'pixelate'
|
|
273
|
-
},
|
|
274
|
-
pixelateFaces: {
|
|
275
|
-
prefix: 'e',
|
|
276
|
-
qualifier: 'pixelate_faces'
|
|
277
|
-
},
|
|
278
|
-
pixelateRegion: {
|
|
279
|
-
prefix: 'e',
|
|
280
|
-
qualifier: 'pixelate_region'
|
|
281
|
-
},
|
|
282
|
-
redeye: {
|
|
283
|
-
prefix: 'e',
|
|
284
|
-
qualifier: 'redeye'
|
|
285
|
-
},
|
|
286
|
-
replaceColor: {
|
|
287
|
-
prefix: 'e',
|
|
288
|
-
qualifier: 'replace_color'
|
|
289
|
-
},
|
|
290
|
-
saturation: {
|
|
291
|
-
prefix: 'e',
|
|
292
|
-
qualifier: 'saturation'
|
|
293
|
-
},
|
|
294
|
-
screen: {
|
|
295
|
-
prefix: 'e',
|
|
296
|
-
qualifier: 'screen'
|
|
297
|
-
},
|
|
298
|
-
sepia: {
|
|
299
|
-
prefix: 'e',
|
|
300
|
-
qualifier: 'sepia'
|
|
301
|
-
},
|
|
302
|
-
shadow: {
|
|
303
|
-
prefix: 'e',
|
|
304
|
-
qualifier: 'shadow'
|
|
305
|
-
},
|
|
306
|
-
sharpen: {
|
|
307
|
-
prefix: 'e',
|
|
308
|
-
qualifier: 'sharpen'
|
|
309
|
-
},
|
|
310
|
-
shear: {
|
|
311
|
-
prefix: 'e',
|
|
312
|
-
qualifier: 'shear'
|
|
313
|
-
},
|
|
314
|
-
simulateColorblind: {
|
|
315
|
-
prefix: 'e',
|
|
316
|
-
qualifier: 'simulate_colorblind'
|
|
317
|
-
},
|
|
318
|
-
tint: {
|
|
319
|
-
prefix: 'e',
|
|
320
|
-
qualifier: 'tint'
|
|
321
|
-
},
|
|
322
|
-
unsharpMask: {
|
|
323
|
-
prefix: 'e',
|
|
324
|
-
qualifier: 'unsharp_mask'
|
|
325
|
-
},
|
|
326
|
-
vectorize: {
|
|
327
|
-
prefix: 'e',
|
|
328
|
-
qualifier: 'vectorize'
|
|
329
|
-
},
|
|
330
|
-
vibrance: {
|
|
331
|
-
prefix: 'e',
|
|
332
|
-
qualifier: 'vibrance'
|
|
333
|
-
},
|
|
334
|
-
vignette: {
|
|
335
|
-
prefix: 'e',
|
|
336
|
-
qualifier: 'vignette'
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
var flags = {
|
|
340
|
-
relative: {
|
|
341
|
-
prefix: 'fl',
|
|
342
|
-
qualifier: 'relative',
|
|
343
|
-
location: 'primary'
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* constructTransformation
|
|
349
|
-
*/
|
|
350
|
-
|
|
351
|
-
function constructTransformation(_ref) {
|
|
352
|
-
var prefix = _ref.prefix,
|
|
353
|
-
qualifier = _ref.qualifier,
|
|
354
|
-
value = _ref.value;
|
|
355
|
-
var transformation = '';
|
|
356
|
-
if (prefix) {
|
|
357
|
-
transformation = prefix + "_";
|
|
358
|
-
}
|
|
359
|
-
if (value === true || value === 'true') {
|
|
360
|
-
return "" + transformation + qualifier;
|
|
361
|
-
}
|
|
362
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
363
|
-
if (prefix) {
|
|
364
|
-
return "" + transformation + qualifier + ":" + value;
|
|
365
|
-
} else {
|
|
366
|
-
return qualifier + "_" + value;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Retrieves the transformations added to a cloudiary image url. If no transformation is recognized it returns an empty array.
|
|
373
|
-
*
|
|
374
|
-
* @param {string} src The cloudiary url.
|
|
375
|
-
*
|
|
376
|
-
* @return {array} The array of transformations
|
|
377
|
-
*/
|
|
378
|
-
|
|
379
|
-
function getTransformations(src, preserveTransformations) {
|
|
380
|
-
if (typeof src !== "string") {
|
|
381
|
-
throw new Error("Invalid src of type " + typeof src);
|
|
382
|
-
}
|
|
383
|
-
if (src.includes("res.cloudinary.com") && preserveTransformations) {
|
|
384
|
-
var regex = new RegExp("(https?)://(res.cloudinary.com)/([^/]+)/(image|video|raw)/(upload|authenticated)/(.*)/(v[0-9]+)/(.+)(?:.[a-z]{3})?", "gi");
|
|
385
|
-
var groups = regex.exec(src);
|
|
386
|
-
var transformationStr = groups.slice(1).find(function (i) {
|
|
387
|
-
return i.includes("_");
|
|
388
|
-
});
|
|
389
|
-
if (transformationStr) {
|
|
390
|
-
return transformationStr.split(",").join("/").split("/");
|
|
391
|
-
} else {
|
|
392
|
-
return [];
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
return [];
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
var props$6 = [].concat(Object.keys(effects), ['effects']);
|
|
399
|
-
function plugin$6(_temp) {
|
|
400
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
401
|
-
cldImage = _ref.cldImage,
|
|
402
|
-
options = _ref.options;
|
|
403
|
-
// Handle any top-level effect props
|
|
404
|
-
|
|
405
|
-
constructTransformationString({
|
|
406
|
-
effects: effects,
|
|
407
|
-
options: options
|
|
408
|
-
}).filter(function (t) {
|
|
409
|
-
return !!t;
|
|
410
|
-
}).forEach(function (transformation) {
|
|
411
|
-
return cldImage.effect(transformation);
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
// If we're passing in an effects prop explicitly, treat it as an array of
|
|
415
|
-
// effects that we need to process
|
|
416
|
-
|
|
417
|
-
if (Array.isArray(options.effects)) {
|
|
418
|
-
options.effects.forEach(function (effectsSet) {
|
|
419
|
-
var transformationString = constructTransformationString({
|
|
420
|
-
effects: effects,
|
|
421
|
-
options: effectsSet
|
|
422
|
-
}).filter(function (t) {
|
|
423
|
-
return !!t;
|
|
424
|
-
}).join(',');
|
|
425
|
-
cldImage.effect(transformationString);
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
function constructTransformationString(_ref2) {
|
|
429
|
-
var effects = _ref2.effects,
|
|
430
|
-
options = _ref2.options;
|
|
431
|
-
return Object.keys(effects).map(function (key) {
|
|
432
|
-
var _effects$key = effects[key],
|
|
433
|
-
prefix = _effects$key.prefix,
|
|
434
|
-
qualifier = _effects$key.qualifier;
|
|
435
|
-
return constructTransformation({
|
|
436
|
-
qualifier: qualifier,
|
|
437
|
-
prefix: prefix,
|
|
438
|
-
value: options[key]
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
var effectsPlugin = {
|
|
445
|
-
__proto__: null,
|
|
446
|
-
props: props$6,
|
|
447
|
-
plugin: plugin$6
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* encodeBase64
|
|
452
|
-
*/
|
|
453
|
-
|
|
454
|
-
function encodeBase64(value) {
|
|
455
|
-
if (typeof btoa === 'function') {
|
|
456
|
-
return btoa(value);
|
|
457
|
-
}
|
|
458
|
-
if (typeof Buffer !== 'undefined') {
|
|
459
|
-
return Buffer.from(value).toString('base64');
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
var _excluded$3 = ["publicId", "url", "position", "text", "effects", "appliedEffects"];
|
|
464
|
-
var props$5 = ['text', 'overlays'];
|
|
465
|
-
var DEFAULT_TEXT_OPTIONS = {
|
|
466
|
-
color: 'black',
|
|
467
|
-
fontFamily: 'Arial',
|
|
468
|
-
fontSize: 200,
|
|
469
|
-
fontWeight: 'bold'
|
|
470
|
-
};
|
|
471
|
-
function plugin$5(_temp) {
|
|
472
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
473
|
-
cldImage = _ref.cldImage,
|
|
474
|
-
options = _ref.options;
|
|
475
|
-
var text$1 = options.text,
|
|
476
|
-
_options$overlays = options.overlays,
|
|
477
|
-
overlays = _options$overlays === void 0 ? [] : _options$overlays;
|
|
478
|
-
var type = 'overlay';
|
|
479
|
-
var typeQualifier = 'l';
|
|
480
|
-
if (Array.isArray(overlays)) {
|
|
481
|
-
overlays.forEach(applyOverlay);
|
|
482
|
-
}
|
|
483
|
-
if (typeof text$1 === 'string') {
|
|
484
|
-
applyOverlay({
|
|
485
|
-
text: _extends({}, DEFAULT_TEXT_OPTIONS, {
|
|
486
|
-
text: text$1
|
|
487
|
-
})
|
|
488
|
-
});
|
|
489
|
-
} else if (typeof text$1 === 'object') {
|
|
490
|
-
applyOverlay({
|
|
491
|
-
text: _extends({}, DEFAULT_TEXT_OPTIONS, text$1)
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* applyOverlay
|
|
497
|
-
*/
|
|
498
|
-
|
|
499
|
-
function applyOverlay(_ref2) {
|
|
500
|
-
var publicId = _ref2.publicId,
|
|
501
|
-
url = _ref2.url,
|
|
502
|
-
position$1 = _ref2.position,
|
|
503
|
-
text$1 = _ref2.text,
|
|
504
|
-
_ref2$effects = _ref2.effects,
|
|
505
|
-
layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
|
|
506
|
-
_ref2$appliedEffects = _ref2.appliedEffects,
|
|
507
|
-
appliedEffects = _ref2$appliedEffects === void 0 ? [] : _ref2$appliedEffects,
|
|
508
|
-
options = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
|
|
509
|
-
var hasPublicId = typeof publicId === 'string';
|
|
510
|
-
var hasUrl = typeof url === 'string';
|
|
511
|
-
var hasText = typeof text$1 === 'object' || typeof text$1 === 'string';
|
|
512
|
-
var hasPosition = typeof position$1 === 'object';
|
|
513
|
-
if (!hasPublicId && !hasUrl && !hasText) {
|
|
514
|
-
console.warn("An " + type + " is missing Public ID, URL, or Text");
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
// Start to construct the transformation string using text or the public ID
|
|
519
|
-
// if it's image-based
|
|
520
|
-
|
|
521
|
-
var layerTransformation;
|
|
522
|
-
if (hasText) {
|
|
523
|
-
layerTransformation = typeQualifier + "_text";
|
|
524
|
-
} else if (hasPublicId) {
|
|
525
|
-
layerTransformation = typeQualifier + "_" + publicId.replace(/\//g, ':');
|
|
526
|
-
} else if (hasUrl) {
|
|
527
|
-
layerTransformation = typeQualifier + "_fetch:" + encodeBase64(url);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
// Begin organizing transformations based on what it is and the location
|
|
531
|
-
// it needs to be placed in the URL
|
|
532
|
-
|
|
533
|
-
var primary$1 = [];
|
|
534
|
-
var applied = [];
|
|
535
|
-
|
|
536
|
-
// Gemeral options
|
|
537
|
-
|
|
538
|
-
Object.keys(options).forEach(function (key) {
|
|
539
|
-
if (!primary[key]) return;
|
|
540
|
-
var qualifier = primary[key].qualifier;
|
|
541
|
-
var transformation = constructTransformation({
|
|
542
|
-
qualifier: qualifier,
|
|
543
|
-
value: options[key]
|
|
544
|
-
});
|
|
545
|
-
primary$1.push(transformation);
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
// Layer effects
|
|
549
|
-
// For layer effects we allow both the standard effects to be applied as well
|
|
550
|
-
// as the primary ones like width and height as those can be used to modify
|
|
551
|
-
// the layer after it's created
|
|
552
|
-
|
|
553
|
-
layerEffects.forEach(function (effect) {
|
|
554
|
-
Object.keys(effect).forEach(function (key) {
|
|
555
|
-
var _ref3 = primary[key] || effects[key] || {},
|
|
556
|
-
qualifier = _ref3.qualifier,
|
|
557
|
-
prefix = _ref3.prefix;
|
|
558
|
-
var transformation = constructTransformation({
|
|
559
|
-
qualifier: qualifier,
|
|
560
|
-
prefix: prefix,
|
|
561
|
-
value: effect[key]
|
|
562
|
-
});
|
|
563
|
-
primary$1.push(transformation);
|
|
564
|
-
});
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
// Applied Layer effects
|
|
568
|
-
// Similar to layer effects but they get appended to an additional transformation
|
|
569
|
-
// along with fl_layer_applied
|
|
570
|
-
|
|
571
|
-
appliedEffects.forEach(function (effect) {
|
|
572
|
-
Object.keys(effect).forEach(function (key) {
|
|
573
|
-
var _ref4 = primary[key] || effects[key] || {},
|
|
574
|
-
qualifier = _ref4.qualifier,
|
|
575
|
-
prefix = _ref4.prefix;
|
|
576
|
-
var transformation = constructTransformation({
|
|
577
|
-
qualifier: qualifier,
|
|
578
|
-
prefix: prefix,
|
|
579
|
-
value: effect[key]
|
|
580
|
-
});
|
|
581
|
-
applied.push(transformation);
|
|
582
|
-
});
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
// Text styling
|
|
586
|
-
|
|
587
|
-
if (hasText) {
|
|
588
|
-
if (typeof text$1 === 'string') {
|
|
589
|
-
text$1 = _extends({}, DEFAULT_TEXT_OPTIONS, {
|
|
590
|
-
text: text$1
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
var textTransformations = [];
|
|
594
|
-
Object.keys(text$1).forEach(function (key) {
|
|
595
|
-
if (!text[key]) return;
|
|
596
|
-
var _qualifiersText$key = text[key],
|
|
597
|
-
qualifier = _qualifiersText$key.qualifier,
|
|
598
|
-
location = _qualifiersText$key.location;
|
|
599
|
-
if (location === 'primary') {
|
|
600
|
-
primary$1.push(qualifier + "_" + text$1[key]);
|
|
601
|
-
} else if (qualifier === 'self') {
|
|
602
|
-
textTransformations.push(key);
|
|
603
|
-
} else if (qualifier) {
|
|
604
|
-
textTransformations.push(qualifier + "_" + text$1[key]);
|
|
605
|
-
} else {
|
|
606
|
-
textTransformations.push(text$1[key]);
|
|
607
|
-
}
|
|
608
|
-
});
|
|
609
|
-
layerTransformation = layerTransformation + ":" + textTransformations.join('_') + ":" + text$1.text;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
// Positioning
|
|
613
|
-
|
|
614
|
-
if (hasPosition) {
|
|
615
|
-
Object.keys(position$1).forEach(function (key) {
|
|
616
|
-
if (!position[key]) return;
|
|
617
|
-
var qualifier = position[key].qualifier;
|
|
618
|
-
var transformation = constructTransformation({
|
|
619
|
-
qualifier: qualifier,
|
|
620
|
-
value: position$1[key]
|
|
621
|
-
});
|
|
622
|
-
applied.push(transformation);
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
// Add all primary transformations
|
|
627
|
-
|
|
628
|
-
if (primary$1.length > 0) {
|
|
629
|
-
layerTransformation = layerTransformation + "," + primary$1.join(',');
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
// Add all applied transformations
|
|
633
|
-
|
|
634
|
-
layerTransformation = layerTransformation + "/fl_layer_apply,fl_no_overflow";
|
|
635
|
-
if (applied.length > 0) {
|
|
636
|
-
layerTransformation = layerTransformation + "," + applied.join(',');
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
// Finally add it to the image
|
|
640
|
-
|
|
641
|
-
cldImage.addTransformation(layerTransformation);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
var overlaysPlugin = {
|
|
646
|
-
__proto__: null,
|
|
647
|
-
props: props$5,
|
|
648
|
-
DEFAULT_TEXT_OPTIONS: DEFAULT_TEXT_OPTIONS,
|
|
649
|
-
plugin: plugin$5
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
var props$4 = ['transformations'];
|
|
653
|
-
function plugin$4(_temp) {
|
|
654
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
655
|
-
cldImage = _ref.cldImage,
|
|
656
|
-
options = _ref.options;
|
|
657
|
-
var _options$transformati = options.transformations,
|
|
658
|
-
transformations = _options$transformati === void 0 ? [] : _options$transformati;
|
|
659
|
-
if (!Array.isArray(transformations)) {
|
|
660
|
-
transformations = [transformations];
|
|
661
|
-
}
|
|
662
|
-
transformations.forEach(function (transformation) {
|
|
663
|
-
cldImage.addTransformation("t_" + transformation);
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
var namedTransformationsPlugin = {
|
|
668
|
-
__proto__: null,
|
|
669
|
-
props: props$4,
|
|
670
|
-
plugin: plugin$4
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
var props$3 = ['rawTransformations'];
|
|
674
|
-
function plugin$3(_temp) {
|
|
675
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
676
|
-
cldImage = _ref.cldImage,
|
|
677
|
-
options = _ref.options;
|
|
678
|
-
var _options$rawTransform = options.rawTransformations,
|
|
679
|
-
rawTransformations = _options$rawTransform === void 0 ? [] : _options$rawTransform;
|
|
680
|
-
rawTransformations.forEach(function (transformation) {
|
|
681
|
-
cldImage.addTransformation(transformation);
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
var rawTransformationsPlugin = {
|
|
686
|
-
__proto__: null,
|
|
687
|
-
props: props$3,
|
|
688
|
-
plugin: plugin$3
|
|
689
|
-
};
|
|
690
|
-
|
|
691
|
-
var props$2 = ['removeBackground'];
|
|
692
|
-
function plugin$2(_temp) {
|
|
693
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
694
|
-
cldImage = _ref.cldImage,
|
|
695
|
-
options = _ref.options;
|
|
696
|
-
var _options$removeBackgr = options.removeBackground,
|
|
697
|
-
removeBackground = _options$removeBackgr === void 0 ? false : _options$removeBackgr;
|
|
698
|
-
if (removeBackground) {
|
|
699
|
-
cldImage.effect('e_background_removal');
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
var removeBackgroundPlugin = {
|
|
704
|
-
__proto__: null,
|
|
705
|
-
props: props$2,
|
|
706
|
-
plugin: plugin$2
|
|
707
|
-
};
|
|
708
|
-
|
|
709
|
-
var _excluded$2 = ["publicId", "type", "position", "text", "effects", "flags"];
|
|
710
|
-
var props$1 = ['underlay', 'underlays'];
|
|
711
|
-
function plugin$1(_temp) {
|
|
712
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
713
|
-
cldImage = _ref.cldImage,
|
|
714
|
-
options = _ref.options;
|
|
715
|
-
var underlay = options.underlay,
|
|
716
|
-
_options$underlays = options.underlays,
|
|
717
|
-
underlays = _options$underlays === void 0 ? [] : _options$underlays;
|
|
718
|
-
var typeQualifier = 'u';
|
|
719
|
-
if (Array.isArray(underlays)) {
|
|
720
|
-
underlays.forEach(applyUnderlay);
|
|
721
|
-
}
|
|
722
|
-
if (typeof underlay === 'string') {
|
|
723
|
-
var underlayOptions = {
|
|
724
|
-
publicId: underlay,
|
|
725
|
-
crop: 'fill',
|
|
726
|
-
width: '1.0',
|
|
727
|
-
height: '1.0',
|
|
728
|
-
flags: ['relative']
|
|
729
|
-
};
|
|
730
|
-
applyUnderlay(underlayOptions);
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* applyUnderlay
|
|
735
|
-
*/
|
|
736
|
-
|
|
737
|
-
function applyUnderlay(_ref2) {
|
|
738
|
-
var publicId = _ref2.publicId,
|
|
739
|
-
type = _ref2.type,
|
|
740
|
-
position$1 = _ref2.position,
|
|
741
|
-
_ref2$effects = _ref2.effects,
|
|
742
|
-
layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
|
|
743
|
-
_ref2$flags = _ref2.flags,
|
|
744
|
-
flags$1 = _ref2$flags === void 0 ? [] : _ref2$flags,
|
|
745
|
-
options = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
|
|
746
|
-
var hasPublicId = typeof publicId === 'string';
|
|
747
|
-
var hasPosition = typeof position$1 === 'object';
|
|
748
|
-
if (!hasPublicId) {
|
|
749
|
-
console.warn("An " + type + " is missing a Public ID");
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
// Start to construct the transformation string using text or the public ID
|
|
754
|
-
// if it's image-based
|
|
755
|
-
|
|
756
|
-
var layerTransformation = typeQualifier + "_" + publicId.replace(/\//g, ':');
|
|
757
|
-
|
|
758
|
-
// Begin organizing transformations based on what it is and the location
|
|
759
|
-
// it needs to be placed in the URL
|
|
760
|
-
|
|
761
|
-
var primary$1 = [];
|
|
762
|
-
var applied = [];
|
|
763
|
-
|
|
764
|
-
// Gemeral options
|
|
765
|
-
|
|
766
|
-
Object.keys(options).forEach(function (key) {
|
|
767
|
-
if (!primary[key]) return;
|
|
768
|
-
var qualifier = primary[key].qualifier;
|
|
769
|
-
primary$1.push(qualifier + "_" + options[key]);
|
|
770
|
-
});
|
|
771
|
-
|
|
772
|
-
// Layer effects
|
|
773
|
-
|
|
774
|
-
layerEffects.forEach(function (effect) {
|
|
775
|
-
Object.keys(effect).forEach(function (key) {
|
|
776
|
-
if (!primary[key]) return;
|
|
777
|
-
var qualifier = primary[key].qualifier;
|
|
778
|
-
primary$1.push(qualifier + "_" + effect[key]);
|
|
779
|
-
});
|
|
780
|
-
});
|
|
781
|
-
|
|
782
|
-
// Positioning
|
|
783
|
-
|
|
784
|
-
if (hasPosition) {
|
|
785
|
-
Object.keys(position$1).forEach(function (key) {
|
|
786
|
-
if (!position[key]) return;
|
|
787
|
-
var qualifier = position[key].qualifier;
|
|
788
|
-
applied.push(qualifier + "_" + position$1[key]);
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
// Positioning
|
|
793
|
-
|
|
794
|
-
flags$1.forEach(function (key) {
|
|
795
|
-
if (!flags[key]) return;
|
|
796
|
-
var _qualifiersFlags$key = flags[key],
|
|
797
|
-
qualifier = _qualifiersFlags$key.qualifier,
|
|
798
|
-
prefix = _qualifiersFlags$key.prefix;
|
|
799
|
-
primary$1.push(prefix + "_" + qualifier);
|
|
800
|
-
});
|
|
801
|
-
|
|
802
|
-
// Add all primary transformations
|
|
803
|
-
|
|
804
|
-
layerTransformation = layerTransformation + "," + primary$1.join(',');
|
|
805
|
-
|
|
806
|
-
// Add all applied transformations
|
|
807
|
-
|
|
808
|
-
layerTransformation = layerTransformation + "/fl_layer_apply,fl_no_overflow";
|
|
809
|
-
if (applied.length > 0) {
|
|
810
|
-
layerTransformation = layerTransformation + "," + applied.join(',');
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
// Finally add it to the image
|
|
814
|
-
|
|
815
|
-
cldImage.addTransformation(layerTransformation);
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
var underlaysPlugin = {
|
|
820
|
-
__proto__: null,
|
|
821
|
-
props: props$1,
|
|
822
|
-
plugin: plugin$1
|
|
823
|
-
};
|
|
824
|
-
|
|
825
|
-
var props = ['zoompan'];
|
|
826
|
-
function plugin(_temp) {
|
|
827
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
828
|
-
cldImage = _ref.cldImage,
|
|
829
|
-
options = _ref.options;
|
|
830
|
-
var _options$zoompan = options.zoompan,
|
|
831
|
-
zoompan = _options$zoompan === void 0 ? false : _options$zoompan;
|
|
832
|
-
var overrides = {};
|
|
833
|
-
if (zoompan === true) {
|
|
834
|
-
cldImage.effect('e_zoompan');
|
|
835
|
-
} else if (typeof zoompan === 'string') {
|
|
836
|
-
if (zoompan === 'loop') {
|
|
837
|
-
cldImage.effect('e_zoompan');
|
|
838
|
-
cldImage.effect('e_loop');
|
|
839
|
-
} else {
|
|
840
|
-
cldImage.effect("e_zoompan:" + zoompan);
|
|
841
|
-
}
|
|
842
|
-
} else if (typeof zoompan === 'object') {
|
|
843
|
-
var zoompanEffect = 'e_zoompan';
|
|
844
|
-
if (typeof zoompan.options === 'string') {
|
|
845
|
-
zoompanEffect = "" + zoompanEffect + zoompan.options;
|
|
846
|
-
}
|
|
847
|
-
cldImage.effect(zoompanEffect);
|
|
848
|
-
var loopEffect;
|
|
849
|
-
if (zoompan.loop === true) {
|
|
850
|
-
loopEffect = 'e_loop';
|
|
851
|
-
} else if (typeof zoompan.loop === 'string') {
|
|
852
|
-
loopEffect = "e_loop" + zoompan.loop;
|
|
853
|
-
}
|
|
854
|
-
if (loopEffect) {
|
|
855
|
-
cldImage.effect(loopEffect);
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
if (zoompan !== false) {
|
|
859
|
-
overrides.format = 'gif';
|
|
860
|
-
}
|
|
861
|
-
return {
|
|
862
|
-
options: overrides
|
|
863
|
-
};
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
var zoompanPlugin = {
|
|
867
|
-
__proto__: null,
|
|
868
|
-
props: props,
|
|
869
|
-
plugin: plugin
|
|
870
|
-
};
|
|
871
|
-
|
|
872
|
-
var NEXT_CLOUDINARY_ANALYTICS_ID = 'V';
|
|
873
|
-
|
|
874
37
|
var name = "next-cloudinary";
|
|
875
|
-
var version = "
|
|
38
|
+
var version = "2.0.0";
|
|
876
39
|
var main = "dist/next-cloudinary.umd.js";
|
|
877
40
|
var module = "dist/next-cloudinary.module.js";
|
|
878
41
|
var source = "src/index.ts";
|
|
@@ -884,6 +47,8 @@ var scripts = {
|
|
|
884
47
|
test: "jest"
|
|
885
48
|
};
|
|
886
49
|
var dependencies = {
|
|
50
|
+
"@cloudinary-util/url-loader": "^1.2.4",
|
|
51
|
+
"@cloudinary-util/util": "^1.1.1",
|
|
887
52
|
"@cloudinary/url-gen": "^1.8.6"
|
|
888
53
|
};
|
|
889
54
|
var devDependencies = {
|
|
@@ -915,6 +80,14 @@ var pkg = {
|
|
|
915
80
|
peerDependencies: peerDependencies
|
|
916
81
|
};
|
|
917
82
|
|
|
83
|
+
var NEXT_CLOUDINARY_ANALYTICS_ID = 'V';
|
|
84
|
+
var NEXT_CLOUDINARY_VERSION = pkg.version;
|
|
85
|
+
var NEXT_VERSION = nextPkg.version;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* createPlaceholderUrl
|
|
89
|
+
*/
|
|
90
|
+
|
|
918
91
|
/**
|
|
919
92
|
* pollForProcessingImage
|
|
920
93
|
*/
|
|
@@ -967,95 +140,10 @@ var pollForProcessingImage = function pollForProcessingImage(options) {
|
|
|
967
140
|
return Promise.reject(e);
|
|
968
141
|
}
|
|
969
142
|
};
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
// it's always expected to applied the same way
|
|
975
|
-
rawTransformationsPlugin];
|
|
976
|
-
var cld;
|
|
977
|
-
/**
|
|
978
|
-
* constructCloudinaryUrl
|
|
979
|
-
*/
|
|
980
|
-
function constructCloudinaryUrl(_ref) {
|
|
981
|
-
var options = _ref.options,
|
|
982
|
-
config = _ref.config;
|
|
983
|
-
if (!cld) {
|
|
984
|
-
cld = new Cloudinary(_extends({
|
|
985
|
-
cloud: {
|
|
986
|
-
cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
|
|
987
|
-
}
|
|
988
|
-
}, config));
|
|
989
|
-
}
|
|
990
|
-
var publicId = getPublicId(options == null ? void 0 : options.src);
|
|
991
|
-
var cldImage = cld.image(publicId);
|
|
992
|
-
transformationPlugins.forEach(function (_ref2) {
|
|
993
|
-
var plugin = _ref2.plugin;
|
|
994
|
-
// @ts-ignore
|
|
995
|
-
var _ref3 = plugin({
|
|
996
|
-
cldImage: cldImage,
|
|
997
|
-
options: options
|
|
998
|
-
}) || {},
|
|
999
|
-
pluginOptions = _ref3.options;
|
|
1000
|
-
if (pluginOptions != null && pluginOptions.format && options) {
|
|
1001
|
-
options.format = pluginOptions.format;
|
|
1002
|
-
}
|
|
1003
|
-
if (pluginOptions != null && pluginOptions.width && options) {
|
|
1004
|
-
options.resize = {
|
|
1005
|
-
width: pluginOptions == null ? void 0 : pluginOptions.width
|
|
1006
|
-
};
|
|
1007
|
-
}
|
|
1008
|
-
});
|
|
1009
|
-
if (options != null && options.resize) {
|
|
1010
|
-
var _options$resize = options.resize,
|
|
1011
|
-
width = _options$resize.width,
|
|
1012
|
-
_options$resize$crop = _options$resize.crop,
|
|
1013
|
-
crop = _options$resize$crop === void 0 ? 'scale' : _options$resize$crop;
|
|
1014
|
-
cldImage.effect("c_" + crop + ",w_" + width);
|
|
1015
|
-
}
|
|
1016
|
-
return cldImage.setDeliveryType((options == null ? void 0 : options.deliveryType) || 'upload').format((options == null ? void 0 : options.format) || 'auto').delivery("q_" + ((options == null ? void 0 : options.quality) || 'auto')).toURL({
|
|
1017
|
-
trackedAnalytics: {
|
|
1018
|
-
sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,
|
|
1019
|
-
sdkSemver: pkg.version,
|
|
1020
|
-
techVersion: nextPkg.version
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
/**
|
|
1025
|
-
* Retrieves the public id of a cloudiary image url. If no url is recognized it returns the parameter it self.
|
|
1026
|
-
* If it's recognized that is a url and it's not possible to get the public id, it warns the user.
|
|
1027
|
-
*
|
|
1028
|
-
* @param {string} src The cloudiary url or public id.
|
|
1029
|
-
*
|
|
1030
|
-
* @return {string} The images public id
|
|
1031
|
-
*/
|
|
1032
|
-
function getPublicId(src) {
|
|
1033
|
-
if (typeof src !== 'string') {
|
|
1034
|
-
throw new Error("Invalid src of type " + typeof src);
|
|
1035
|
-
}
|
|
1036
|
-
if (src.includes('res.cloudinary.com')) {
|
|
1037
|
-
var regexWithTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(.*)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
|
|
1038
|
-
var regexWithoutTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
|
|
1039
|
-
var withTransformations = src.match(regexWithTransformations);
|
|
1040
|
-
var withoutTransformations = src.match(regexWithoutTransformations);
|
|
1041
|
-
if (withTransformations) {
|
|
1042
|
-
return withTransformations[withTransformations.length - 1];
|
|
1043
|
-
} else if (withoutTransformations) {
|
|
1044
|
-
return withoutTransformations[withoutTransformations.length - 1];
|
|
1045
|
-
} else {
|
|
1046
|
-
console.warn("Not possible to retrieve the publicUrl from " + src + ", make sure it's a valid cloudinary image url.");
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
return src;
|
|
1050
|
-
}
|
|
1051
|
-
/**
|
|
1052
|
-
* createPlaceholderUrl
|
|
1053
|
-
*/
|
|
1054
|
-
function createPlaceholderUrl(_ref4) {
|
|
1055
|
-
var src = _ref4.src,
|
|
1056
|
-
_ref4$placeholder = _ref4.placeholder,
|
|
1057
|
-
placeholder = _ref4$placeholder === void 0 ? true : _ref4$placeholder,
|
|
1058
|
-
config = _ref4.config;
|
|
143
|
+
function createPlaceholderUrl(_ref) {
|
|
144
|
+
var src = _ref.src,
|
|
145
|
+
_ref$placeholder = _ref.placeholder,
|
|
146
|
+
placeholder = _ref$placeholder === void 0 ? true : _ref$placeholder;
|
|
1059
147
|
var rawTransformations = [];
|
|
1060
148
|
if (placeholder === 'grayscale') {
|
|
1061
149
|
rawTransformations.push('e_grayscale');
|
|
@@ -1072,7 +160,17 @@ function createPlaceholderUrl(_ref4) {
|
|
|
1072
160
|
quality: 1,
|
|
1073
161
|
rawTransformations: rawTransformations
|
|
1074
162
|
},
|
|
1075
|
-
config:
|
|
163
|
+
config: {
|
|
164
|
+
cloud: {
|
|
165
|
+
cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
analytics: {
|
|
169
|
+
sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,
|
|
170
|
+
sdkSemver: NEXT_CLOUDINARY_VERSION,
|
|
171
|
+
techVersion: NEXT_VERSION,
|
|
172
|
+
feature: ''
|
|
173
|
+
}
|
|
1076
174
|
});
|
|
1077
175
|
}
|
|
1078
176
|
|
|
@@ -1098,7 +196,17 @@ function cloudinaryLoader(_ref) {
|
|
|
1098
196
|
}
|
|
1099
197
|
return constructCloudinaryUrl({
|
|
1100
198
|
options: options,
|
|
1101
|
-
config:
|
|
199
|
+
config: _extends({
|
|
200
|
+
cloud: {
|
|
201
|
+
cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
|
|
202
|
+
}
|
|
203
|
+
}, cldConfig),
|
|
204
|
+
analytics: {
|
|
205
|
+
sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,
|
|
206
|
+
sdkSemver: NEXT_CLOUDINARY_VERSION,
|
|
207
|
+
techVersion: NEXT_VERSION,
|
|
208
|
+
feature: ''
|
|
209
|
+
}
|
|
1102
210
|
});
|
|
1103
211
|
}
|
|
1104
212
|
|
|
@@ -1162,7 +270,15 @@ var CldImage = function CldImage(props) {
|
|
|
1162
270
|
//
|
|
1163
271
|
// https://nextjs.org/docs/api-reference/next/image#blurdataurl
|
|
1164
272
|
if (imageProps.placeholder) {
|
|
1165
|
-
var publicId
|
|
273
|
+
var publicId;
|
|
274
|
+
if (props.src.startsWith('https://')) {
|
|
275
|
+
try {
|
|
276
|
+
publicId = getPublicId(props.src);
|
|
277
|
+
} catch (e) {}
|
|
278
|
+
}
|
|
279
|
+
if (!publicId) {
|
|
280
|
+
publicId = props.src;
|
|
281
|
+
}
|
|
1166
282
|
imageProps.blurDataURL = createPlaceholderUrl({
|
|
1167
283
|
src: publicId,
|
|
1168
284
|
placeholder: props.placeholder
|
|
@@ -1198,14 +314,26 @@ var CldOgImage = function CldOgImage(_ref) {
|
|
|
1198
314
|
twitterTitle = _ref.twitterTitle,
|
|
1199
315
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
1200
316
|
var options = _extends({}, props, {
|
|
1201
|
-
|
|
1202
|
-
height: props.height || IMAGE_HEIGHT,
|
|
317
|
+
alt: props.alt,
|
|
1203
318
|
crop: props.crop || 'fill',
|
|
1204
319
|
gravity: props.gravity || 'center',
|
|
1205
|
-
|
|
320
|
+
height: props.height || IMAGE_HEIGHT,
|
|
321
|
+
src: props.src,
|
|
322
|
+
width: props.width || IMAGE_WIDTH
|
|
1206
323
|
});
|
|
1207
324
|
var ogImageUrl = constructCloudinaryUrl({
|
|
1208
|
-
options: options
|
|
325
|
+
options: options,
|
|
326
|
+
config: {
|
|
327
|
+
cloud: {
|
|
328
|
+
cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
analytics: {
|
|
332
|
+
sdkCode: NEXT_CLOUDINARY_ANALYTICS_ID,
|
|
333
|
+
sdkSemver: NEXT_CLOUDINARY_VERSION,
|
|
334
|
+
techVersion: NEXT_VERSION,
|
|
335
|
+
feature: ''
|
|
336
|
+
}
|
|
1209
337
|
});
|
|
1210
338
|
// We need to include the tags within the Next.js Head component rather than
|
|
1211
339
|
// direcly adding them inside of the Head otherwise we get unexpected results
|
|
@@ -1370,5 +498,5 @@ var CldUploadButton = function CldUploadButton(_ref) {
|
|
|
1370
498
|
});
|
|
1371
499
|
};
|
|
1372
500
|
|
|
1373
|
-
export { CldImage, CldOgImage, CldUploadButton, CldUploadWidget, cloudinaryLoader
|
|
501
|
+
export { CldImage, CldOgImage, CldUploadButton, CldUploadWidget, cloudinaryLoader };
|
|
1374
502
|
//# sourceMappingURL=next-cloudinary.module.js.map
|