Skip to content

Commit

Permalink
MIM-1964:Fixed imageUrl if only two pictureCard
Browse files Browse the repository at this point in the history
  • Loading branch information
ssb-cgn committed Dec 16, 2024
1 parent 50e66ad commit 749f8dc
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function parsePictureCardLinks(
const subTitle: string = pictureCardLink.subTitle
const href: string = pictureCardLink.href

const imageSources = createImageUrls(pictureCardLink, i)
const imageSources = createImageUrls(pictureCardLink, pictureCardLinks.length, i)

const pictureCardLinksContent: PictureCardLinksContent = {
title: title,
Expand All @@ -63,7 +63,7 @@ function parsePictureCardLinks(
}, [])
}

function createImageUrls(pictureCardLink: PictureCardLink, i: number): ImageUrls {
function createImageUrls(pictureCardLink: PictureCardLink, listLength: number, i: number): ImageUrls {
const imageUrls: ImageUrls = {
portraitSrcSet: '',
landscapeSrcSet: '',
Expand All @@ -78,7 +78,11 @@ function createImageUrls(pictureCardLink: PictureCardLink, i: number): ImageUrls
})

imageUrls.landscapeSrcSet = imageUrls.imageSrc
if (i > 0) imageUrls.portraitSrcSet = imageUrls.imageSrc.replace('block-580-400', 'block-280-400')

if (listLength === 4 || (listLength === 3 && i > 0)) {
imageUrls.portraitSrcSet = imageUrls.imageSrc.replace('block-580-400', 'block-280-400')
}

imageUrls.imageAlt = getImageAlt(pictureCardLink.image) || ''
} else {
imageUrls.imageSrc = imagePlaceholder({
Expand Down

0 comments on commit 749f8dc

Please sign in to comment.