Skip to content

Commit

Permalink
Merge pull request #222 from hlxsites/maxed/img-tweaks
Browse files Browse the repository at this point in the history
fix: article image search params
  • Loading branch information
maxakuru authored Oct 17, 2023
2 parents 8c2d599 + f018604 commit e6af5a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 5 additions & 3 deletions blocks/article/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,12 @@ const decorateImages = (block) => {
return;
}

const picEl = pic.tagName === 'PICTURE' ? pic : image;
const imageWrapper = document.createElement('div');
// Use data selector to prevent franklin from automatically trying to load a block
imageWrapper.setAttribute('data-class', 'image-wrapper');
image.insertAdjacentElement('afterend', imageWrapper);
imageWrapper.append(image);
picEl.insertAdjacentElement('afterend', imageWrapper);
imageWrapper.append(picEl);
}
};

Expand Down Expand Up @@ -437,9 +438,10 @@ async function renderContent(block, res, rerender = false) {

const picture = image.parentElement;
if (picture.tagName === 'PICTURE') {
const [baseUrl] = image.src.split('?');
for (const source of picture.querySelectorAll('source')) {
const search = source.srcset.split('?')[1];
source.srcset = `${image.src}?${search}`;
source.srcset = `${baseUrl}?${search}`;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,6 @@ export const showRoute = (hash, targetCategoryId) => {
const player = targetCategory.querySelector('lottie-player');
if (!player.classList.contains('has-loaded')) {
const categoryRouteId = hash.substring(1, hash.length);
console.log('categoryRouteId: ', categoryRouteId);
try {
// Load via URL
player.load(LOTTIE_PATHS[categoryRouteId]);
Expand Down

0 comments on commit e6af5a1

Please sign in to comment.