Skip to content

Commit

Permalink
SITES-22935 NGDM remote image issue
Browse files Browse the repository at this point in the history
Incorporate changes done in other PR - b5e6a56
  • Loading branch information
mohiaror committed Jul 1, 2024
1 parent 36d7f2d commit f97f697
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
var imagePresetRadio = ".cmp-image__editor-dynamicmedia-presettype input[name='./dmPresetType'][value='imagePreset']";
var smartCropRadio = ".cmp-image__editor-dynamicmedia-presettype input[name='./dmPresetType'][value='smartCrop']";
var remoteFileReferencesArray = [];
var remoteFileReference;

$(document).on("dialog-loaded", function(e) {
altTextFromPage = undefined;
Expand Down Expand Up @@ -119,8 +120,8 @@
if (!fileReference) {
var $fileReferences = $cqFileUpload.find("[data-cq-fileupload-parameter='filereference']");
$fileReferences.each(function() {
var remoteFileReference = $(this).val();
if (remoteFileReference && remoteFileReference.includes("urn:aaid:aem")) {
remoteFileReference = $(this).val();
if (isRemoteFileReference(remoteFileReference)) {
smartCropRenditionFromJcr = "NONE"; // for newly selected asset we clear the smartcrop selection dropdown
processFileReference(remoteFileReference);
}
Expand Down Expand Up @@ -359,11 +360,11 @@
}

function isRemoteFileReference(fileReference) {
return fileReference && fileReference !== "" && fileReference.includes("urn:aaid:aem");
return fileReference && fileReference.includes("urn:aaid:aem");
}

function retrieveDAMInfo(fileReference) {
if (fileReference.startsWith("/urn:aaid:aem")) {
if (isRemoteFileReference(fileReference)) {
return new Promise((resolve, reject) => {
fileReference = fileReference.substring(0, fileReference.lastIndexOf("/"));
if (isPolarisEnabled && areDMFeaturesEnabled) {
Expand Down Expand Up @@ -421,11 +422,11 @@
// can be shown on initial load. Also adding condition filePath.endsWith("/cq:featuredimage") to trigger alt
// update for page properties.
remoteFileReferencesArray.each(function() {
var remoteFileReference = $(this).val();
remoteFileReference = $(this).val();
if (filePath.endsWith("/cq:featuredimage")) {
remoteFileReference = data["fileReference"];
}
if (remoteFileReference && remoteFileReference !== "" && remoteFileReference.includes("urn:aaid:aem") || filePath.endsWith("/cq:featuredimage")) {
if (isRemoteFileReference(remoteFileReference) || filePath.endsWith("/cq:featuredimage")) {
retrieveDAMInfo(remoteFileReference);
}
});
Expand Down

0 comments on commit f97f697

Please sign in to comment.