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 almost 7 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 #1

Updated by Gerrit Code Review over 7 years ago

  • Status changed from New to Under Review

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52538

Actions #2

Updated by Gerrit Code Review over 7 years ago

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52540

Actions #3

Updated by Benni Mack over 7 years ago

  • Target version changed from 8 LTS to next-patchlevel
Actions #4

Updated by Benni Mack almost 7 years ago

  • Status changed from Under Review to Rejected

"default" is just an arbitrary crop variant id. it is neither required nor recommend to be used.

the image viewhelpers delivered by the core should not implement such fallback logic.

instead such logic should be implemented in own project specific view helpers if needed

Actions

Also available in: Atom PDF