From 749f8dc7be1e73503110e8a2ec6550008e60de5e Mon Sep 17 00:00:00 2001 From: Carina Date: Mon, 16 Dec 2024 14:47:51 +0100 Subject: [PATCH] MIM-1964:Fixed imageUrl if only two pictureCard --- .../site/parts/pictureCardLinks/pictureCardLinks.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/resources/site/parts/pictureCardLinks/pictureCardLinks.ts b/src/main/resources/site/parts/pictureCardLinks/pictureCardLinks.ts index e0641174a..f005c8ab8 100644 --- a/src/main/resources/site/parts/pictureCardLinks/pictureCardLinks.ts +++ b/src/main/resources/site/parts/pictureCardLinks/pictureCardLinks.ts @@ -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, @@ -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: '', @@ -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({