Skip to content

Commit

Permalink
Merge pull request #41 from asad-rafter/CLD-338-PGW-rendering-bundle
Browse files Browse the repository at this point in the history
CLD-338-rendering-PGW
  • Loading branch information
yuval-cloudinary authored Jan 29, 2025
2 parents 018a043 + bd70463 commit 5681b8c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@

<iscomment> Custom Start: include cloudinary shrinkwrap. </iscomment>
<isset name="CLDImagePageTypeSettings" value="${JSON.parse(dw.system.Site.current.preferences.custom.CLDImagePageTypeSettings)}" scope="page"/>
<isif condition="${dw.system.Site.current.preferences.custom.CLDGalleryEnabled}">
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}"></script>
<script>
window.cldProductGallery = cloudinary;
</script>
</isif>
<isif condition="${(CLDImagePageTypeSettings.pdp.enabled && CLDImagePageTypeSettings.pdp.automateResponsivenessWithJS) || (CLDImagePageTypeSettings.cldPdpSwatch.enabled && CLDImagePageTypeSettings.cldPdpSwatch.automateResponsivenessWithJS)}">
<isinclude template="include/cloudinaryShrinkwrap"/>
</isif>
Expand Down Expand Up @@ -56,6 +50,7 @@
<iscomment>Custom start: add cloudinary PGW</iscomment>
<isif condition="${pdict.cloudinary && pdict.cloudinary.isEnabled && (pdict.cloudinary.galleryEnabled || pdict.cloudinary.isGalleryEnabled)}">
<isinclude template="product/components/cloudinaryGallery" />
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" onload="window.cldProductGallery = cloudinary; window.renderCloudinaryGalleryWidget();"> </script>
<iselse>
<!-- Product Images Carousel -->
<isinclude template="product/components/imageCarousel" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

<iscomment> Custom Start: include cloudinary shrinkwrap. </iscomment>
<isset name="CLDImagePageTypeSettings" value="${JSON.parse(dw.system.Site.current.preferences.custom.CLDImagePageTypeSettings)}" scope="page"/>
<isif condition="${dw.system.Site.current.preferences.custom.CLDGalleryEnabled}">
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" />
</isif>
<isif condition="${(CLDImagePageTypeSettings.pdp.enabled && CLDImagePageTypeSettings.pdp.automateResponsivenessWithJS) || (CLDImagePageTypeSettings.cldPdpSwatch.enabled && CLDImagePageTypeSettings.cldPdpSwatch.automateResponsivenessWithJS)}">
<isinclude template="include/cloudinaryShrinkwrap"/>
</isif>
Expand Down Expand Up @@ -42,6 +39,7 @@
<iscomment>Custom start: add cloudinary PGW</iscomment>
<isif condition="${pdict.cloudinary && pdict.cloudinary.isEnabled && pdict.cloudinary.galleryEnabled}">
<isinclude template="product/components/cloudinaryGallery" />
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" onload="window.cldProductGallery = cloudinary; window.renderCloudinaryGalleryWidget();"> </script>
<isset name="isBundleOrSet" value="${false}" scope="page" />
<iselse>
<!-- Product Images Carousel -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@

<iscomment> Custom Start: include cloudinary shrinkwrap. </iscomment>
<isset name="CLDImagePageTypeSettings" value="${JSON.parse(dw.system.Site.current.preferences.custom.CLDImagePageTypeSettings)}" scope="page"/>
<isif condition="${dw.system.Site.current.preferences.custom.CLDGalleryEnabled}">
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}"></script>
<script>
window.cldProductGallery = cloudinary;
</script>
</isif>
<isif condition="${(CLDImagePageTypeSettings.pdp.enabled && CLDImagePageTypeSettings.pdp.automateResponsivenessWithJS) || (CLDImagePageTypeSettings.cldPdpSwatch.enabled && CLDImagePageTypeSettings.cldPdpSwatch.automateResponsivenessWithJS)}">
<isinclude template="include/cloudinaryShrinkwrap"/>
</isif>
Expand Down Expand Up @@ -58,6 +52,10 @@
</div>
</div>
<isinclude template="product/components/setItems" />

<isif condition="${dw.system.Site.current.preferences.custom.CLDGalleryEnabled}">
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" onload="window.cldProductGallery = cloudinary; window.renderCloudinarySetGalleryWidgets();"></script>
</isif>
<hr>
<iscomment>Custom start: Add cloudinary video player</iscomment>
<isif condition="${pdict.cloudinary && pdict.cloudinary.isEnabled && pdict.cloudinary.videoEnabled}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
</isif>

<isif condition="${dw.system.Site.current.preferences.custom.CLDGalleryEnabled}">
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}"></script>
<script>
window.cldProductGallery = cloudinary;
</script>
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" onload="window.cldProductGallery = cloudinary; window.renderCloudinaryGalleryWidget();"></script>
</isif>
<iscomment> Custom End: include cloudinary shrinkwrap. </iscomment>

Expand Down
12 changes: 5 additions & 7 deletions cartridges/int_cloudinary/cartridge/js/cloudinaryWidgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ window.renderCloudinaryGalleryWidget = function () {
galleryOptions.SecureDistribution = cloudinaryObj.domain;
galleryOptions.privateCdn = true;
}
window.cldGallery = window.cldProductGallery ? window.cldProductGallery.galleryWidget(galleryOptions) : cloudinary.galleryWidget(galleryOptions); // eslint-disable-line no-undef
cldGallery.render(); // eslint-disable-line no-undef
window.cldGallery = window.cldProductGallery ? window.cldProductGallery.galleryWidget(galleryOptions) : (cloudinary.galleryWidget && cloudinary.galleryWidget(galleryOptions)); // eslint-disable-line no-undef
window.cldGallery && cldGallery.render(); // eslint-disable-line no-undef
} else if (cloudinaryObj.images && cloudinaryObj.images.imageURLs) {
imgUrls = cloudinaryObj.images.imageURLs;
}
Expand All @@ -41,8 +41,8 @@ window.renderCloudinarySetGalleryWidgets = function () {
cldSetImages.galleryWidget.options.SecureDistribution = cldObj.domain;
cldSetImages.galleryWidget.options.privateCdn = true;
}
window.cldGallery = window.cldProductGallery.galleryWidget(cldSetImages.galleryWidget.options); // eslint-disable-line no-undef
cldGallery.render(); // eslint-disable-line no-undef
window.cldGallery = window.cldProductGallery ? window.cldProductGallery.galleryWidget(cldSetImages.galleryWidget.options) : (cloudinary.galleryWidget && cloudinary.galleryWidget(cldSetImages.galleryWidget.options)); // eslint-disable-line no-undef
window.cldGallery && cldGallery.render(); // eslint-disable-line no-undef
}
});
};
Expand Down Expand Up @@ -82,17 +82,15 @@ window.makeCloudinaryImagesResponsive = function () {
var $cldEl = $('.cloudinary-data-container');
var cloudinaryObj = $cldEl.data('cloudinary');
if ($cldResponsiveImgTags && $cldResponsiveImgTags.length > 0) {
if ( window.cldObj === undefined && window.cloudinary && window.cloudinary.default) {
if (window.cldObj === undefined && window.cloudinary && window.cloudinary.default) {
window.cldObj = window.cloudinary.default.Cloudinary.new({ cloud_name: cloudinaryObj.cloudName || cloudinaryObj });
}
window.cldObj && window.cldObj.responsive(); // eslint-disable-line no-undef
}
};

$(document).ready(function () {
window.renderCloudinaryGalleryWidget();
window.renderCloudinaryVideoPlayer();
window.renderCloudinarySetGalleryWidgets();
window.makeCloudinaryImagesResponsive();

$('.icon-next, .icon-prev').on('click', function () {
Expand Down

0 comments on commit 5681b8c

Please sign in to comment.