next-cloudinary 0.2.0 → 0.3.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/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  ######
14
14
 
15
15
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
16
- [![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-)
16
+ [![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors-)
17
17
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
18
18
 
19
19
  # Cloudinary Next.js Component
@@ -292,6 +292,8 @@ See the examples above under Overlays to learn more about the available configur
292
292
  <tr>
293
293
  <td align="center"><a href="http://joanleon.dev"><img src="https://avatars.githubusercontent.com/u/1307927?v=4?s=100" width="100px;" alt="Joan León"/><br /><sub><b>Joan León</b></sub></a><br /><a href="https://github.com/colbyfayock/next-cloudinary/commits?author=nucliweb" title="Documentation">📖</a></td>
294
294
  <td align="center"><a href="http://www.timbenniks.dev"><img src="https://avatars.githubusercontent.com/u/121096?v=4?s=100" width="100px;" alt="Tim Benniks"/><br /><sub><b>Tim Benniks</b></sub></a><br /><a href="https://github.com/colbyfayock/next-cloudinary/commits?author=timbenniks" title="Code">💻</a> <a href="https://github.com/colbyfayock/next-cloudinary/commits?author=timbenniks" title="Documentation">📖</a></td>
295
+ <td align="center"><a href="https://github.com/csgochan"><img src="https://avatars.githubusercontent.com/u/116420257?v=4?s=100" width="100px;" alt="csgochan"/><br /><sub><b>csgochan</b></sub></a><br /><a href="https://github.com/colbyfayock/next-cloudinary/commits?author=csgochan" title="Documentation">📖</a></td>
296
+ <td align="center"><a href="https://github.com/codingis4noobs2"><img src="https://avatars.githubusercontent.com/u/87560178?v=4?s=100" width="100px;" alt="codingis4noobs2"/><br /><sub><b>codingis4noobs2</b></sub></a><br /><a href="https://github.com/colbyfayock/next-cloudinary/commits?author=codingis4noobs2" title="Code">💻</a> <a href="https://github.com/colbyfayock/next-cloudinary/commits?author=codingis4noobs2" title="Tests">⚠️</a></td>
295
297
  </tr>
296
298
  </tbody>
297
299
  </table>
@@ -1,12 +1,14 @@
1
1
  var Image = require('next/image');
2
2
  var urlGen = require('@cloudinary/url-gen');
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
+ var Head = require('next/head');
4
5
  var react = require('react');
5
6
  var Script = require('next/script');
6
7
 
7
8
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
9
 
9
10
  var Image__default = /*#__PURE__*/_interopDefaultLegacy(Image);
11
+ var Head__default = /*#__PURE__*/_interopDefaultLegacy(Head);
10
12
  var Script__default = /*#__PURE__*/_interopDefaultLegacy(Script);
11
13
 
12
14
  function _extends() {
@@ -41,96 +43,32 @@ function _objectWithoutPropertiesLoose(source, excluded) {
41
43
  return target;
42
44
  }
43
45
 
44
- function _readOnlyError(name) {
45
- throw new TypeError("\"" + name + "\" is read-only");
46
- }
47
-
48
- var cld$1 = new urlGen.Cloudinary({
49
- cloud: {
50
- cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
51
- },
52
- url: {
53
- // Used to avoid issues with SSR particularly for the blurred placeholder
54
- analytics: false
55
- }
56
- });
57
- /**
58
- * Retrieves the public id of a cloudiary image url. If no url is recognized it returns the parameter it self.
59
- * If it's recognized that is a url and it's not possible to get the public id, it warns the user.
60
- *
61
- * @param {string} src The cloudiary url or public id.
62
- *
63
- * @return {string} The images public id
64
- */
65
-
66
- function getPublicId(src) {
67
- if (src.includes('res.cloudinary.com')) {
68
- var regexWithTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(.*)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
69
- var regexWithoutTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
70
- var withTransformations = src.match(regexWithTransformations);
71
- var withoutTransformations = src.match(regexWithoutTransformations);
72
-
73
- if (withTransformations) {
74
- return withTransformations[withTransformations.length - 1];
75
- } else if (withoutTransformations) {
76
- return withoutTransformations[withoutTransformations.length - 1];
77
- } else {
78
- console.warn("Not possible to retrieve the publicUrl from " + src + ", make sure it's a valid cloudinary image url.");
79
- }
80
- }
81
-
82
- return src;
83
- }
84
- /**
85
- * createPlaceholderUrl
86
- */
87
-
88
- function createPlaceholderUrl(_ref) {
89
- var src = _ref.src,
90
- placeholder = _ref.placeholder;
91
- var cldImage = cld$1.image(src).resize('c_limit,w_100').delivery('q_1').format('auto');
92
-
93
- if (placeholder === 'grayscale') {
94
- cldImage.effect('e_grayscale');
95
- }
96
-
97
- if (placeholder.includes('color:')) {
98
- var color = placeholder.split(':').splice(1).join(':');
99
- cldImage.effect('e_grayscale');
100
- cldImage.effect("e_colorize:60,co_" + color);
101
- }
102
-
103
- return cldImage.toURL();
104
- }
105
-
106
46
  var cropsGravityAuto = ['crop', 'fill', 'lfill', 'fill_pad', 'thumb'];
107
47
  var props$6 = ['crop', 'gravity'];
108
48
  function plugin$6(_temp) {
109
49
  var _ref = _temp === void 0 ? {} : _temp,
110
50
  cldImage = _ref.cldImage,
111
- options = _ref.options,
112
- cldOptions = _ref.cldOptions;
51
+ options = _ref.options;
113
52
 
114
53
  var width = options.width,
115
- height = options.height;
116
- var _cldOptions$crop = cldOptions.crop,
117
- crop = _cldOptions$crop === void 0 ? 'limit' : _cldOptions$crop,
118
- gravity = cldOptions.gravity;
54
+ height = options.height,
55
+ _options$crop = options.crop,
56
+ crop = _options$crop === void 0 ? 'limit' : _options$crop;
119
57
  var transformationString = "c_" + crop + ",w_" + width;
120
58
 
121
- if (!gravity && cropsGravityAuto.includes(crop)) {
122
- _readOnlyError("gravity");
59
+ if (!options.gravity && cropsGravityAuto.includes(crop)) {
60
+ options.gravity = 'auto';
123
61
  }
124
62
 
125
63
  if (!['limit'].includes(crop)) {
126
64
  transformationString = transformationString + ",h_" + height;
127
65
  }
128
66
 
129
- if (gravity) {
130
- if (gravity === 'auto' && !cropsGravityAuto.includes(crop)) {
67
+ if (options.gravity) {
68
+ if (options.gravity === 'auto' && !cropsGravityAuto.includes(crop)) {
131
69
  console.warn('Auto gravity can only be used with crop, fill, lfill, fill_pad or thumb. Not applying gravity.');
132
70
  } else {
133
- transformationString = transformationString + ",g_" + gravity;
71
+ transformationString = transformationString + ",g_" + options.gravity;
134
72
  }
135
73
  }
136
74
 
@@ -195,20 +133,16 @@ var props$5 = params.map(function (param) {
195
133
  function plugin$5(_temp) {
196
134
  var _ref = _temp === void 0 ? {} : _temp,
197
135
  cldImage = _ref.cldImage,
198
- cldOptions = _ref.cldOptions;
136
+ options = _ref.options;
199
137
 
200
138
  params.forEach(function (key) {
201
139
  var prop = key.prop || key;
202
140
  var effect = key.effect || key;
203
141
 
204
- if (prop === 'oilPaint' && cldOptions[prop]) {
205
- console.log('cldOptions[prop]', cldOptions[prop]);
206
- }
207
-
208
- if (cldOptions[prop] === true) {
142
+ if (options[prop] === true) {
209
143
  cldImage.effect("e_" + effect);
210
- } else if (typeof cldOptions[prop] === 'string') {
211
- cldImage.effect("e_" + effect + ":" + cldOptions[prop]);
144
+ } else if (typeof options[prop] === 'string') {
145
+ cldImage.effect("e_" + effect + ":" + options[prop]);
212
146
  }
213
147
  });
214
148
  }
@@ -273,27 +207,55 @@ var text = {
273
207
  }
274
208
  };
275
209
 
276
- var _excluded$2 = ["publicId", "position", "text", "effects"];
277
- var props$4 = ['overlays'];
210
+ var _excluded$3 = ["publicId", "position", "text", "effects"];
211
+ var props$4 = ['text', 'overlays'];
212
+ var DEFAULT_TEXT_OPTIONS = {
213
+ color: 'black',
214
+ fontFamily: 'Arial',
215
+ fontSize: 200,
216
+ fontWeight: 'bold'
217
+ };
278
218
  function plugin$4(_temp) {
279
219
  var _ref = _temp === void 0 ? {} : _temp,
280
220
  cldImage = _ref.cldImage,
281
- cldOptions = _ref.cldOptions;
221
+ options = _ref.options;
282
222
 
283
- var _cldOptions$overlays = cldOptions.overlays,
284
- overlays = _cldOptions$overlays === void 0 ? [] : _cldOptions$overlays;
223
+ var text$1 = options.text,
224
+ _options$overlays = options.overlays,
225
+ overlays = _options$overlays === void 0 ? [] : _options$overlays;
285
226
  var type = 'overlay';
286
227
  var typeQualifier = 'l';
287
- overlays.forEach(function (_ref2) {
228
+
229
+ if (Array.isArray(overlays)) {
230
+ overlays.forEach(applyOverlay);
231
+ }
232
+
233
+ if (typeof text$1 === 'string') {
234
+ applyOverlay({
235
+ text: _extends({}, DEFAULT_TEXT_OPTIONS, {
236
+ text: text$1
237
+ })
238
+ });
239
+ } else if (typeof text$1 === 'object') {
240
+ applyOverlay({
241
+ text: _extends({}, DEFAULT_TEXT_OPTIONS, text$1)
242
+ });
243
+ }
244
+ /**
245
+ * applyOverlay
246
+ */
247
+
248
+
249
+ function applyOverlay(_ref2) {
288
250
  var publicId = _ref2.publicId,
289
251
  position$1 = _ref2.position,
290
252
  text$1 = _ref2.text,
291
253
  _ref2$effects = _ref2.effects,
292
254
  layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
293
- options = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
255
+ options = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
294
256
 
295
257
  var hasPublicId = typeof publicId === 'string';
296
- var hasText = typeof text$1 === 'object';
258
+ var hasText = typeof text$1 === 'object' || typeof text$1 === 'string';
297
259
  var hasPosition = typeof position$1 === 'object';
298
260
 
299
261
  if (!hasPublicId && !hasText) {
@@ -331,6 +293,12 @@ function plugin$4(_temp) {
331
293
  }); // Text styling
332
294
 
333
295
  if (hasText) {
296
+ if (typeof text$1 === 'string') {
297
+ text$1 = _extends({}, DEFAULT_TEXT_OPTIONS, {
298
+ text: text$1
299
+ });
300
+ }
301
+
334
302
  var textTransformations = [];
335
303
  Object.keys(text$1).forEach(function (key) {
336
304
  if (!text[key]) return;
@@ -359,7 +327,7 @@ function plugin$4(_temp) {
359
327
 
360
328
  layerTransformation = layerTransformation + "," + primary$1.join(','); // Add all applied transformations
361
329
 
362
- layerTransformation = layerTransformation + "/fl_layer_apply";
330
+ layerTransformation = layerTransformation + "/fl_layer_apply,fl_no_overflow";
363
331
 
364
332
  if (applied.length > 0) {
365
333
  layerTransformation = layerTransformation + "," + applied.join(',');
@@ -367,12 +335,13 @@ function plugin$4(_temp) {
367
335
 
368
336
 
369
337
  cldImage.addTransformation(layerTransformation);
370
- });
338
+ }
371
339
  }
372
340
 
373
341
  var overlaysPlugin = {
374
342
  __proto__: null,
375
343
  props: props$4,
344
+ DEFAULT_TEXT_OPTIONS: DEFAULT_TEXT_OPTIONS,
376
345
  plugin: plugin$4
377
346
  };
378
347
 
@@ -380,10 +349,10 @@ var props$3 = ['rawTransformations'];
380
349
  function plugin$3(_temp) {
381
350
  var _ref = _temp === void 0 ? {} : _temp,
382
351
  cldImage = _ref.cldImage,
383
- cldOptions = _ref.cldOptions;
352
+ options = _ref.options;
384
353
 
385
- var _cldOptions$rawTransf = cldOptions.rawTransformations,
386
- rawTransformations = _cldOptions$rawTransf === void 0 ? [] : _cldOptions$rawTransf;
354
+ var _options$rawTransform = options.rawTransformations,
355
+ rawTransformations = _options$rawTransform === void 0 ? [] : _options$rawTransform;
387
356
  rawTransformations.forEach(function (transformation) {
388
357
  cldImage.addTransformation(transformation);
389
358
  });
@@ -399,10 +368,10 @@ var props$2 = ['removeBackground'];
399
368
  function plugin$2(_temp) {
400
369
  var _ref = _temp === void 0 ? {} : _temp,
401
370
  cldImage = _ref.cldImage,
402
- cldOptions = _ref.cldOptions;
371
+ options = _ref.options;
403
372
 
404
- var _cldOptions$removeBac = cldOptions.removeBackground,
405
- removeBackground = _cldOptions$removeBac === void 0 ? false : _cldOptions$removeBac;
373
+ var _options$removeBackgr = options.removeBackground,
374
+ removeBackground = _options$removeBackgr === void 0 ? false : _options$removeBackgr;
406
375
 
407
376
  if (removeBackground) {
408
377
  cldImage.effect('e_background_removal');
@@ -415,23 +384,50 @@ var removeBackgroundPlugin = {
415
384
  plugin: plugin$2
416
385
  };
417
386
 
418
- var _excluded$1 = ["publicId", "type", "position", "text", "effects"];
419
- var props$1 = ['underlays'];
387
+ var _excluded$2 = ["publicId", "type", "position", "text", "effects"];
388
+ var props$1 = ['underlay', 'underlays'];
420
389
  function plugin$1(_temp) {
421
390
  var _ref = _temp === void 0 ? {} : _temp,
422
391
  cldImage = _ref.cldImage,
423
- cldOptions = _ref.cldOptions;
392
+ options = _ref.options;
424
393
 
425
- var _cldOptions$underlays = cldOptions.underlays,
426
- underlays = _cldOptions$underlays === void 0 ? [] : _cldOptions$underlays;
394
+ var underlay = options.underlay,
395
+ _options$underlays = options.underlays,
396
+ underlays = _options$underlays === void 0 ? [] : _options$underlays;
427
397
  var typeQualifier = 'u';
428
- underlays.forEach(function (_ref2) {
398
+
399
+ if (Array.isArray(underlays)) {
400
+ underlays.forEach(applyUnderlay);
401
+ }
402
+
403
+ if (typeof underlay === 'string') {
404
+ var underlayOptions = {
405
+ publicId: underlay,
406
+ crop: 'fill'
407
+ };
408
+
409
+ if (options.width) {
410
+ underlayOptions.width = options.width;
411
+ }
412
+
413
+ if (options.height) {
414
+ underlayOptions.height = options.height;
415
+ }
416
+
417
+ applyUnderlay(underlayOptions);
418
+ }
419
+ /**
420
+ * applyUnderlay
421
+ */
422
+
423
+
424
+ function applyUnderlay(_ref2) {
429
425
  var publicId = _ref2.publicId,
430
426
  type = _ref2.type,
431
427
  position$1 = _ref2.position,
432
428
  _ref2$effects = _ref2.effects,
433
429
  layerEffects = _ref2$effects === void 0 ? [] : _ref2$effects,
434
- options = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
430
+ options = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
435
431
 
436
432
  var hasPublicId = typeof publicId === 'string';
437
433
  var hasPosition = typeof position$1 === 'object';
@@ -474,7 +470,7 @@ function plugin$1(_temp) {
474
470
 
475
471
  layerTransformation = layerTransformation + "," + primary$1.join(','); // Add all applied transformations
476
472
 
477
- layerTransformation = layerTransformation + "/fl_layer_apply";
473
+ layerTransformation = layerTransformation + "/fl_layer_apply,fl_no_overflow";
478
474
 
479
475
  if (applied.length > 0) {
480
476
  layerTransformation = layerTransformation + "," + applied.join(',');
@@ -482,7 +478,7 @@ function plugin$1(_temp) {
482
478
 
483
479
 
484
480
  cldImage.addTransformation(layerTransformation);
485
- });
481
+ }
486
482
  }
487
483
 
488
484
  var underlaysPlugin = {
@@ -495,11 +491,11 @@ var props = ['zoompan'];
495
491
  function plugin(_temp) {
496
492
  var _ref = _temp === void 0 ? {} : _temp,
497
493
  cldImage = _ref.cldImage,
498
- cldOptions = _ref.cldOptions;
494
+ options = _ref.options;
499
495
 
500
- var _cldOptions$zoompan = cldOptions.zoompan,
501
- zoompan = _cldOptions$zoompan === void 0 ? false : _cldOptions$zoompan;
502
- var options = {};
496
+ var _options$zoompan = options.zoompan,
497
+ zoompan = _options$zoompan === void 0 ? false : _options$zoompan;
498
+ var overrides = {};
503
499
 
504
500
  if (zoompan === true) {
505
501
  cldImage.effect('e_zoompan');
@@ -532,11 +528,11 @@ function plugin(_temp) {
532
528
  }
533
529
 
534
530
  if (zoompan !== false) {
535
- options.format = 'gif';
531
+ overrides.format = 'gif';
536
532
  }
537
533
 
538
534
  return {
539
- options: options
535
+ options: overrides
540
536
  };
541
537
  }
542
538
 
@@ -546,15 +542,18 @@ var zoompanPlugin = {
546
542
  plugin: plugin
547
543
  };
548
544
 
549
- var cld;
550
545
  var transformationPlugins = [// Background Removal must always come first
551
546
  removeBackgroundPlugin, croppingPlugin, effectsPlugin, overlaysPlugin, underlaysPlugin, zoompanPlugin, // Raw transformations needs to be last simply to make sure
552
547
  // it's always expected to applied the same way
553
548
  rawTransformationsPlugin];
554
- function cloudinaryLoader(defaultOptions, cldOptions, cldConfig) {
555
- if (cldConfig === void 0) {
556
- cldConfig = {};
557
- }
549
+ var cld;
550
+ /**
551
+ * constructCloudinaryUrl
552
+ */
553
+
554
+ function constructCloudinaryUrl(_ref) {
555
+ var options = _ref.options,
556
+ config = _ref.config;
558
557
 
559
558
  if (!cld) {
560
559
  cld = new urlGen.Cloudinary(_extends({
@@ -565,31 +564,98 @@ function cloudinaryLoader(defaultOptions, cldOptions, cldConfig) {
565
564
  // Used to avoid issues with SSR particularly for the blurred placeholder
566
565
  analytics: false
567
566
  }
568
- }, cldConfig));
567
+ }, config));
569
568
  }
570
569
 
571
- var options = _extends({
572
- format: 'auto',
573
- quality: 'auto'
574
- }, defaultOptions);
575
-
576
570
  var publicId = getPublicId(options.src);
577
571
  var cldImage = cld.image(publicId);
578
- transformationPlugins.forEach(function (_ref) {
579
- var plugin = _ref.plugin;
572
+ transformationPlugins.forEach(function (_ref2) {
573
+ var plugin = _ref2.plugin;
580
574
 
581
- var _ref2 = plugin({
575
+ var _ref3 = plugin({
582
576
  cldImage: cldImage,
583
- options: options,
584
- cldOptions: cldOptions
577
+ options: options
585
578
  }) || {},
586
- pluginOptions = _ref2.options;
579
+ pluginOptions = _ref3.options;
587
580
 
588
581
  if (pluginOptions != null && pluginOptions.format) {
589
582
  options.format = pluginOptions.format;
590
583
  }
591
584
  });
592
- return cldImage.format(options.format).delivery("q_" + options.quality).toURL();
585
+ return cldImage.setDeliveryType(options.deliveryType || 'upload').format(options.format || 'auto').delivery("q_" + (options.quality || 'auto')).toURL();
586
+ }
587
+ /**
588
+ * Retrieves the public id of a cloudiary image url. If no url is recognized it returns the parameter it self.
589
+ * If it's recognized that is a url and it's not possible to get the public id, it warns the user.
590
+ *
591
+ * @param {string} src The cloudiary url or public id.
592
+ *
593
+ * @return {string} The images public id
594
+ */
595
+
596
+ function getPublicId(src) {
597
+ if (typeof src !== 'string') {
598
+ throw new Error("Invalid src of type " + typeof src);
599
+ }
600
+
601
+ if (src.includes('res.cloudinary.com')) {
602
+ var regexWithTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(.*)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
603
+ var regexWithoutTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
604
+ var withTransformations = src.match(regexWithTransformations);
605
+ var withoutTransformations = src.match(regexWithoutTransformations);
606
+
607
+ if (withTransformations) {
608
+ return withTransformations[withTransformations.length - 1];
609
+ } else if (withoutTransformations) {
610
+ return withoutTransformations[withoutTransformations.length - 1];
611
+ } else {
612
+ console.warn("Not possible to retrieve the publicUrl from " + src + ", make sure it's a valid cloudinary image url.");
613
+ }
614
+ }
615
+
616
+ return src;
617
+ }
618
+ /**
619
+ * createPlaceholderUrl
620
+ */
621
+
622
+ function createPlaceholderUrl(_ref4) {
623
+ var src = _ref4.src,
624
+ _ref4$placeholder = _ref4.placeholder,
625
+ placeholder = _ref4$placeholder === void 0 ? true : _ref4$placeholder,
626
+ config = _ref4.config;
627
+ var rawTransformations = [];
628
+
629
+ if (placeholder === 'grayscale') {
630
+ rawTransformations.push('e_grayscale');
631
+ }
632
+
633
+ if (typeof placeholder === 'string' && placeholder.includes('color:')) {
634
+ var color = placeholder.split(':').splice(1).join(':');
635
+ rawTransformations.push('e_grayscale');
636
+ rawTransformations.push("e_colorize:60,co_" + color);
637
+ }
638
+
639
+ return constructCloudinaryUrl({
640
+ options: {
641
+ src: src,
642
+ width: 100,
643
+ quality: 1,
644
+ rawTransformations: rawTransformations
645
+ },
646
+ config: config
647
+ });
648
+ }
649
+
650
+ function cloudinaryLoader(defaultOptions, cldOptions, cldConfig) {
651
+ if (cldConfig === void 0) {
652
+ cldConfig = {};
653
+ }
654
+
655
+ return constructCloudinaryUrl({
656
+ options: _extends({}, defaultOptions, cldOptions),
657
+ config: cldConfig
658
+ });
593
659
  }
594
660
 
595
661
  var CldImage = function CldImage(props) {
@@ -648,6 +714,58 @@ var CldImage = function CldImage(props) {
648
714
  }));
649
715
  };
650
716
 
717
+ var _excluded$1 = ["excludeTags", "twitterTitle"];
718
+ var IMAGE_WIDTH = 2400;
719
+ var IMAGE_HEIGHT = 1200;
720
+ var TWITTER_CARD = 'summary_large_image';
721
+
722
+ var CldOgImage = function CldOgImage(_ref) {
723
+ var _ref$excludeTags = _ref.excludeTags,
724
+ excludeTags = _ref$excludeTags === void 0 ? [] : _ref$excludeTags,
725
+ twitterTitle = _ref.twitterTitle,
726
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
727
+
728
+ var options = _extends({}, props, {
729
+ width: props.width || IMAGE_WIDTH,
730
+ height: props.height || IMAGE_HEIGHT,
731
+ crop: props.crop || 'fill',
732
+ gravity: props.gravity || 'center'
733
+ });
734
+
735
+ var ogImageUrl = constructCloudinaryUrl({
736
+ options: options
737
+ }); // We need to include the tags within the Next.js Head component rather than
738
+ // direcly adding them inside of the Head otherwise we get unexpected results
739
+
740
+ return /*#__PURE__*/jsxRuntime.jsxs(Head__default["default"], {
741
+ children: [/*#__PURE__*/jsxRuntime.jsx("meta", {
742
+ property: "og:image",
743
+ content: ogImageUrl
744
+ }), /*#__PURE__*/jsxRuntime.jsx("meta", {
745
+ property: "og:image:secure_url",
746
+ content: ogImageUrl
747
+ }), /*#__PURE__*/jsxRuntime.jsx("meta", {
748
+ property: "og:image:width",
749
+ content: options.width
750
+ }), /*#__PURE__*/jsxRuntime.jsx("meta", {
751
+ property: "og:image:height",
752
+ content: options.height
753
+ }), options.alt && /*#__PURE__*/jsxRuntime.jsx("meta", {
754
+ property: "og:image:alt",
755
+ content: options.alt
756
+ }), !excludeTags.includes('twitter:title') && /*#__PURE__*/jsxRuntime.jsx("meta", {
757
+ property: "twitter:title",
758
+ content: twitterTitle || ' '
759
+ }), /*#__PURE__*/jsxRuntime.jsx("meta", {
760
+ property: "twitter:card",
761
+ content: TWITTER_CARD
762
+ }), /*#__PURE__*/jsxRuntime.jsx("meta", {
763
+ property: "twitter:image",
764
+ content: ogImageUrl
765
+ })]
766
+ });
767
+ };
768
+
651
769
  var CldUploadWidget = function CldUploadWidget(_ref) {
652
770
  var children = _ref.children,
653
771
  onUpload = _ref.onUpload,
@@ -779,6 +897,7 @@ var CldUploadButton = function CldUploadButton(_ref) {
779
897
  };
780
898
 
781
899
  exports.CldImage = CldImage;
900
+ exports.CldOgImage = CldOgImage;
782
901
  exports.CldUploadButton = CldUploadButton;
783
902
  exports.CldUploadWidget = CldUploadWidget;
784
903
  exports.cloudinaryLoader = cloudinaryLoader;