Project

General

Profile

Actions

Bug #101520

closed

Crop variant editor doesn't remember certain crop area positions

Added by Robert Kärner 9 months ago. Updated 28 days ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
Image Cropping
Target version:
-
Start date:
2023-08-01
Due date:
% Done:

100%

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

Description

Short Description:
The image cropping editor in the backend has problems remembering the crop area of an image under certain circumstances.
This happens when a aspect ratio setting is active and the crop area touches both the left and the right border of the actual image.

Steps to reproduce:
  • Setup and install a fresh version of TYPO3 v12 or v11. I haven't tested v10 or lower, so the issue might happen there as well.
  • Add this additional TCA override configuration:
    $GLOBALS['TCA']['pages']['columns']['media']['config']['overrideChildTca']['columns']['crop']['config'] = [
        'cropVariants' => [
            'desktop' => [
                'title' => 'Desktop',
                'allowedAspectRatios' => [
                    '16:5' => [
                        'title' => '16:5',
                        'value' => 16 / 5
                    ]
                ]
            ],
            'mobile' => [
                'title' => 'Mobile',
                'allowedAspectRatios' => [
                    '11:5' => [
                        'title' => '11:5',
                        'value' => 11 / 5
                    ]
                ],
                'selectedRatio' => '11:5'
            ]
        ]
    ];
    
  • Upload any image you like to the installation. You can use the provided example image of a railroad attached to this issue. This image is public domain and free of copyright restrictions (http://www.publicdomainfiles.com/show_file.php?id=13940998218719)
  • Create a new empty page in the backend page tree.
  • Add the image to the page resources (Resources > Media > Create new relation)
  • Save the page record (optional)
  • Open the image manipulation editor
  • Create or move the crop area so that it touches the left, the bottom and the right border of the actual image:
  • Click Accept
  • Save the page record (optional)
  • The IRRE shows the correctly cropped part of the image as a thumbnail (and it would work perfectly fine in frontend as well)
  • Open the image manipulation editor again
  • Expectation: The editor shows the correct position of the cropped area, but instead it is somewhere in the center:
  • Move the cropped area to the bottom again
  • This time, don't click Accept, but switch to the Mobile crop variant and then back to Desktop
  • The cropped area has moved again. However, the orange rectangle on the thumbnail top right still shows the old bottom position:
  • Again, switch to the Mobile crop variant and then back to Desktop
  • Now the thumbnail has finally updated:
  • Try again with a) the cropped area sitting at the top (touching left, top and right), b) somewhere else in the middle (only touching left and right). The same bug will occur.
  • Now try again with the cropped area only touching the left, only the right or no borders at all. Now the bug won't appear and everything works as expected.

Files

the-railroad-goes-into-the-distance.jpg (698 KB) the-railroad-goes-into-the-distance.jpg Robert Kärner, 2023-08-01 10:39
crop_01.png (1.32 MB) crop_01.png Robert Kärner, 2023-08-01 10:56
crop_02.png (1.17 MB) crop_02.png Robert Kärner, 2023-08-01 11:00
crop_03.png (1.17 MB) crop_03.png Robert Kärner, 2023-08-01 11:02
crop_04.png (1.17 MB) crop_04.png Robert Kärner, 2023-08-01 11:02
Actions #1

Updated by LUKA netconsult 5 months ago

I can confirm that.
Can also observe this for the image manipulation in content elements. Applies not only to crops that touch the bottom and top edges but also to crops that touch the top and bottom edges.

Actions #2

Updated by Daniel Gorges 4 months ago

I can confirm that too. This behavior affects TYPO3 11 aswell.

Actions #3

Updated by LUKA netconsult 3 months ago

Hi, is there any news on this topic yet? Has anyone been able to look into the case and reproduce the error?

Actions #4

Updated by Julian Mair 3 months ago

can confirm in both Typo3 v11 and v12

Actions #5

Updated by Kevin Appelt 2 months ago

I've just encountered the same issue (in v12) and have put some investigation in.
It seems like as soon as both sides (left and right) are "touched", the x-coordinate will be something like 4.02e-6 (which translates to 0.00000402).
My guess is, that something(tm) in the JS only sees "4", which is quite to big for the valid range of 0 to 1, and weird stuff happens.
This issue does not seem to happen if the image in the cropping area is not resized. If I try the same thing with a 600x400 image, it works like expected. But an image of the size 3000x2000 does result in this behaviour.

I hope that helps someone who understands much more of the JS stuff going on than me to track down the issue and resolve it.
I am happy to help as much as I can and provide more information if needed :)

Actions #6

Updated by Andreas Kienast 29 days ago

This appears to be an upstream bug: https://github.com/fengyuanchen/cropperjs/issues/373

Actions #7

Updated by Gerrit Code Review 29 days ago

  • Status changed from New to Under Review

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

Actions #8

Updated by Gerrit Code Review 29 days ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83644

Actions #9

Updated by Gerrit Code Review 28 days ago

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

Actions #10

Updated by Gerrit Code Review 28 days ago

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

Actions #11

Updated by Andreas Fernandez 28 days ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF