@nuskin/cs-product-lib 1.1.0 → 1.1.1
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/package.json +1 -1
- package/src/helpers.js +17 -8
package/package.json
CHANGED
package/src/helpers.js
CHANGED
|
@@ -498,7 +498,7 @@ function mapPoints(parent) {
|
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
/* istanbul ignore next */
|
|
501
|
-
function mapImage(image) {
|
|
501
|
+
function mapImage(image, useWebp = false) {
|
|
502
502
|
if (Array.isArray(image)) {
|
|
503
503
|
image = image[0]
|
|
504
504
|
}
|
|
@@ -520,10 +520,17 @@ function mapImage(image) {
|
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
522
|
if ((image || {}).derivatives) {
|
|
523
|
+
const derivatives = image.derivatives || {}
|
|
523
524
|
// isSvg will only work if a public link to the original derivative is authored on the bynder asset.
|
|
524
|
-
const isSvg =
|
|
525
|
+
const isSvg = derivatives.original && derivatives.original.includes('.svg');
|
|
526
|
+
let imgURL = derivatives.webImage
|
|
527
|
+
if (isSvg) {
|
|
528
|
+
imgURL = derivatives.original
|
|
529
|
+
} else if (useWebp && derivatives.transformBaseUrl) {
|
|
530
|
+
imgURL = `${derivatives.transformBaseUrl}.webp`
|
|
531
|
+
}
|
|
525
532
|
return {
|
|
526
|
-
url:
|
|
533
|
+
url: imgURL,
|
|
527
534
|
alt:
|
|
528
535
|
(image.meta || {}).SEO_Tags ||
|
|
529
536
|
image.description ||
|
|
@@ -848,10 +855,12 @@ function mapIngredients(ings, legacyIngredients) {
|
|
|
848
855
|
return ings.map((ingredients) => ({
|
|
849
856
|
keyIngredients: ((ingredients || {}).key_ingredients || []).map(
|
|
850
857
|
(keyIngredient) => ({
|
|
851
|
-
image:
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
858
|
+
image: !isNullOrEmpty(keyIngredient.icon_bynder)
|
|
859
|
+
? mapImage(keyIngredient.icon_bynder, true)
|
|
860
|
+
: {
|
|
861
|
+
url: (keyIngredient.icon || {}).url,
|
|
862
|
+
alt: (keyIngredient.icon || {}).title
|
|
863
|
+
},
|
|
855
864
|
name: keyIngredient.header,
|
|
856
865
|
description: keyIngredient.description
|
|
857
866
|
})
|
|
@@ -885,7 +894,7 @@ function mapIngredients(ings, legacyIngredients) {
|
|
|
885
894
|
{
|
|
886
895
|
keyIngredients: keyIngredients.map((keyIngredient) => ({
|
|
887
896
|
image: !isNullOrEmpty(keyIngredient.icon_bynder)
|
|
888
|
-
? mapImage(keyIngredient.icon_bynder)
|
|
897
|
+
? mapImage(keyIngredient.icon_bynder, true)
|
|
889
898
|
: {
|
|
890
899
|
url: (keyIngredient.icon || {}).url,
|
|
891
900
|
alt: (keyIngredient.icon || {}).title
|