We're updating the issue view to help you get more done. 

Cannot use picture tag with generated DAM renditions

Description

Requirement

We want to use HTML picture tag to display DAM renditions.

Code details

Below backend code of the component:

1 2 3 4 5 6 7 8 9 10 11 12 MediaBuilder builder = mediaHandler.get(resource); MediaFormat CONTENT = create("content") .label("All content") .extensions("gif", "jpg", "jpeg", "png") .build(); builder = builder.mediaFormat(CONTENT); for (long width : allowedRenditionWidthsFromComponentPolicy) { builder = builder.pictureSource(CONTENT, "(max-width: " + width + "px)", width); } media = builder.build();

Below generated html:

1 2 3 4 5 6 7 <picture> <source media="(max-width: 200px)" srcset="/content/dam/project/example-image.jpg/_jcr_content/renditions/example-image.jpg.rendition.200.200.jpg./example-image.jpg.rendition.200.200.jpg 200w"> <source media="(max-width: 320px)" srcset="/content/dam/project/example-image.jpg/_jcr_content/renditions/original.image_file.320.126.file/example-image.jpg 320w"> <source media="(max-width: 540px)" srcset="/content/dam/project/example-image.jpg/_jcr_content/renditions/example-image.jpg.rendition.540.540.jpg./example-image.jpg.rendition.540.540.jpg 540w"> <source media="(max-width: 800px)" srcset="/content/dam/project/example-image.jpg/_jcr_content/renditions/original.image_file.800.314.file/example-image.jpg 800w"> <img src="/content/dam/project/example-image.jpg/_jcr_content/renditions/original./example-image.jpg" alt="example-image.jpg"> </picture>

Description

This was possible by remove in `media/src/main/java/io/wcm/handler/media/impl/MediaBuilderImpl.java`
checking `ensureMediaFormatHasRatio()`

If we add ratio to the builder the connection to DAM will be lost and every rendition will be generated on the fly and pointed under /content/... path, what is not expected from Caching Strategy point of view - if image in DAM will be changed then instead of invalidating one path in DAM we need to invalidate many under /content.

Proposed solution:

Could you add some way to skip ratio validation? Or we should implement our requirements differently?

Environment

None

Status

Assignee

Stefan Seifert

Reporter

Krzysztof Gorzynski

Labels

None

Components

Fix versions

Affects versions

Media Handler 1.5.0

Priority

Major