Skip to content

Commit

Permalink
svg image
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Sep 4, 2023
1 parent 2a032e9 commit bbe307f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ protected List<Long> buildRenditionWidths() {
* @return Url pattern
*/
protected String buildSrcPattern() {
UriTemplate uriTempalte = media.getRendition().getUriTemplate(UriTemplateType.SCALE_WIDTH);
Rendition rendition = media.getRendition();
if (!rendition.isImage() || rendition.isVectorImage()) {
return null;
}
UriTemplate uriTempalte = rendition.getUriTemplate(UriTemplateType.SCALE_WIDTH);
return StringUtils.replace(uriTempalte.getUriTemplate(), URI_TEMPLATE_PLACEHOLDER_WIDTH, WIDTH_PLACEHOLDER);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,23 @@ void testWithAssetImage() {
assertInvalidLink(underTest.getImageLink());
}

@Test
void testWithAssetImage_SVG() {
Asset svgAsset = context.create().asset(DAM_ROOT + "/sample.svg", 160, 90, ContentType.SVG);

context.currentResource(context.create().resource(page, "image",
PROPERTY_RESOURCE_TYPE, RESOURCE_TYPE,
PN_IMAGE_FROM_PAGE_IMAGE, false,
PN_MEDIA_REF_STANDARD, svgAsset.getPath()));

Image underTest = AdaptTo.notNull(context.request(), Image.class);

String expectedMediaUrl = DAM_ROOT + "/sample.svg/_jcr_content/renditions/original./sample.svg";

assertEquals(expectedMediaUrl, underTest.getSrc());
assertNull(underTest.getSrcUriTemplate());
}

@Test
@SuppressWarnings({ "deprecation", "null" })
void testWithAssetImageFromPage() {
Expand Down

0 comments on commit bbe307f

Please sign in to comment.