#80845f:image and f:uri.image viewhelpers don't fall back to default crop
Description
f:image and f:uri.image viewhelpers should fall back to default crop if no other more specific crop has been set but the default crop has been set.
Actually (version 8.7.0) the 2 viewhelpers set $cropArea here
$cropArea = $cropVariantCollection->getCropArea($cropVariant);
and then set ‘crop’ processing istruction based on the fact that the editor did set or not a crop area
'crop' => $cropArea->isEmpty() ? null : $cropArea->makeAbsoluteBasedOnFile($image)
But if we pass a $cropVariant as argument (ie: ‘medium’) and the editor didn’t set that crop but did set the default crop, then the image is not cropped while it should be croppet to the default crop set by the editor.
A code like this solves the problem:
// if selected cropVariant has empty area then fall back to 'default' crop variant
$crop = null;
if ($cropArea->isEmpty()) {
if ($cropVariant != 'default') {
$cropArea = $cropVariantCollection->getCropArea('default');
$crop = $cropArea->isEmpty() ? null : $cropArea->makeAbsoluteBasedOnFile($image);
}
} else {
$crop = $cropArea->makeAbsoluteBasedOnFile($image);
}
and then then set ‘crop’ processing istruction to $crop:
'crop' => $crop