Skip to content

Commit

Permalink
reduce complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Jan 17, 2024
1 parent d63a95d commit 3c22143
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,19 @@ private void addRendition(Set<RenditionMetadata> candidates, Rendition rendition
* @return Cropping dimensions or empty list if not found
*/
private @NotNull List<CropDimension> getDynamicMediaCropDimensions(MediaArgs mediaArgs) {
if (mediaArgs.getMediaFormatOptions() == null) {
MediaFormatOption[] mediaFormatOptions = mediaArgs.getMediaFormatOptions();
if (mediaFormatOptions == null) {
return Collections.emptyList();
}
List<CropDimension> result = new ArrayList<>();
MediaFormatOption[] mediaFormatOptions = mediaArgs.getMediaFormatOptions();
if (mediaFormatOptions != null) {
for (MediaFormatOption mediaFormatOption : mediaFormatOptions) {
MediaFormat mediaFormat = mediaFormatOption.getMediaFormat();
if (mediaFormat != null && mediaFormat.hasRatio()) {
NamedDimension smartCropDef = SmartCrop.getDimensionForRatio(damContext.getImageProfile(), mediaFormat.getRatio());
if (smartCropDef != null) {
CropDimension cropDimension = SmartCrop.getCropDimensionForAsset(damContext.getAsset(), damContext.getResourceResolver(), smartCropDef);
if (cropDimension != null) {
result.add(cropDimension);
}
for (MediaFormatOption mediaFormatOption : mediaFormatOptions) {
MediaFormat mediaFormat = mediaFormatOption.getMediaFormat();
if (mediaFormat != null && mediaFormat.hasRatio()) {
NamedDimension smartCropDef = SmartCrop.getDimensionForRatio(damContext.getImageProfile(), mediaFormat.getRatio());
if (smartCropDef != null) {
CropDimension cropDimension = SmartCrop.getCropDimensionForAsset(damContext.getAsset(), damContext.getResourceResolver(), smartCropDef);
if (cropDimension != null) {
result.add(cropDimension);
}
}
}
Expand Down

0 comments on commit 3c22143

Please sign in to comment.