Rendition Picking with activated Cropping

Description

Currently if the component defines cropping parameter, the CropRenditionHandler will only consider the original rendition and the default web rendition, generated by DAM Asset Update Workflow.

It would be helpful if the {{CropRenditionHandler}} would also consider other rendition, which could have been uploaded by the editor and only favor the virtual crop rendition for media formats with the matching ratio.

Thus it would be possible to solve scenarios for responsive images like:

  • a component defines an image, which requires three images with different ratios to be displayed in different breakpoints

  • an editor can upload an original rendition for the biggest breakpoint, additional rendition for the middle breakpoint and crop the original rendition for the smallest breakpoint. if the editor uploads additional rendition for the smallest breakpoint, the virtual crop rendition would still be favourized

Activity

Show:
Igor Sechyn
December 9, 2014, 8:22 AM

sorry. done in 31d8b86

Stefan Seifert
December 8, 2014, 8:53 PM

please update changes.xml as well...

Igor Sechyn
December 8, 2014, 8:26 PM

ok, thanks. i have merged the branch into the branch. seems to work fine, all tests are passing and i have tested on a project.

Stefan Seifert
December 8, 2014, 4:52 PM

i've done some minor code optimizations in rev. 9eca17 to more reduce the usage of protected fields/methods between the two rendition handler implementations, but did no substantial changes save the fallback handling if cropping for the web rendition was not possible.

i'm fine with applying this to the trunk if all unit tests pass and it solves your usecases.

Igor Sechyn
December 7, 2014, 7:12 PM

hi stefan,

i have commited a possible solution on the https://github.com/wcm-io/wcm-io/tree/WCMIO-40 branch. the main idea behind it was to include all renditions in the candidate list of the CropRenditionHandler and not only the virtual and original one. the virtual rendition is handled with the highest priority though

along the way i have refactored both Crop and Default Handlers a little bit to make it more suitable for inheritance.

as far as i could see all the tests passed except for the one checking the invalid crop dimensions. since the requested media format could also be served by one of the actual renditions, the crop rendition handler now falls back to it. if there are no actual renditions to match the media format. the img element is null (i have also added a test for that). if the virtual rendition and an actual rendition match the media format, virtual rendition is always preferred.

it seems to be a very simple solution, maybe you could have a look at it and see if i missed something.

Fixed

Assignee

Unassigned

Reporter

Igor Sechyn

Labels

None

Components

Fix versions

Priority

Major