Skip to content

Commit

Permalink
teaser img handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Sm1pleScr1pt committed Oct 11, 2024
1 parent 48192e6 commit 8fd625d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion blocks/moredetailsaddress/moredetailsaddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ export function dropDownStateCity(response) {

async function getReviewRating(placeID) {
return new Promise((resolve, reject) => {
fetchAPI('GET', `https://maps.googleapis.com/maps/api/place/details/json?place_id=${placeID}&key=AIzaSyDx1HwnCLjSSIm_gADqaYAZhSBh7hgcwTQ`) // api for the get request
// https://maps.googleapis.com/maps/api/place/details/json?place_id=${placeID}&key=AIzaSyDx1HwnCLjSSIm_gADqaYAZhSBh7hgcwTQ
fetchAPI('GET', `/content/piramalfinance-eds/mapapi.json?place_id=${placeID}&key=AIzaSyDx1HwnCLjSSIm_gADqaYAZhSBh7hgcwTQ`) // api for the get request
.then((response) => response.json())
.then((data) => resolve(data)).catch((error) => console.log(error));

Expand Down
2 changes: 1 addition & 1 deletion blocks/teaser/teaser.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function generateTeaserDOM(props, classes) {
ctaImageAnchor2.innerHTML = ctaImage2.innerHTML;
ctaImageAnchor3.innerHTML = ctaImage3.innerHTML;
// const bgPictureStyle = bgPicture?.querySelector("img")?.src || '';
const bgPictureStyle = bgPicture?.querySelector('img')?.src ? ` style='background-image:url(${bgPicture?.querySelector('img')?.src})' ` : '';
const bgPictureStyle = bgPicture?.querySelector('img')?.src && bgPicture?.querySelector('img').src.split("?")[0] ? ` style='background-image:url(${bgPicture?.querySelector('img').src.split("?")[0]})' ` : '';
const mobileImageStyle = mobileImage?.querySelector('img')?.src ? ` style='background-image:url(${mobileImage?.querySelector('img')?.src})' ` : '';
let bgImageAllow = bgPictureStyle;
if (targetObject.isTab) {
Expand Down
9 changes: 3 additions & 6 deletions scripts/aem.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ function createOptimizedPicture(
const source = document.createElement('source');
if (br.media) source.setAttribute('media', br.media);
source.setAttribute('type', 'image/webp');
// source.setAttribute('srcset', `${pathname}?width=${br.width}&format=webply&optimize=medium`);
source.setAttribute('srcset', `${pathname}`);
source.setAttribute('srcset', `${pathname}?width=${br.width}&format=webply&optimize=medium`);
picture.appendChild(source);
});

Expand All @@ -349,16 +348,14 @@ function createOptimizedPicture(
if (i < breakpoints.length - 1) {
const source = document.createElement('source');
if (br.media) source.setAttribute('media', br.media);
// source.setAttribute('srcset', `${pathname}?width=${br.width}&format=${ext}&optimize=medium`);
source.setAttribute('srcset', `${pathname}`);
source.setAttribute('srcset', `${pathname}?width=${br.width}&format=${ext}&optimize=medium`);
picture.appendChild(source);
} else {
const img = document.createElement('img');
img.setAttribute('loading', eager ? 'eager' : 'lazy');
img.setAttribute('alt', alt);
picture.appendChild(img);
// img.setAttribute('src', `${pathname}?width=${br.width}&format=${ext}&optimize=medium`);
img.setAttribute('src', `${pathname}`);
img.setAttribute('src', `${pathname}?width=${br.width}&format=${ext}&optimize=medium`);
}
});

Expand Down

0 comments on commit 8fd625d

Please sign in to comment.