Project

General

Profile

Actions

Bug #80845

closed

f:image and f:uri.image viewhelpers don't fall back to default crop

Added by Ian Solo over 7 years ago. Updated over 6 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
Start date:
2017-04-14
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

Actions

Also available in: Atom PDF