Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crop method not called in ImageResizer #1185

Closed
mjauvin opened this issue Aug 19, 2024 · 6 comments
Closed

crop method not called in ImageResizer #1185

mjauvin opened this issue Aug 19, 2024 · 6 comments

Comments

@mjauvin
Copy link
Member

mjauvin commented Aug 19, 2024

Winter CMS Build

dev-develop

PHP Version

8.1

Database engine

MySQL/MariaDB

Plugins installed

No response

Issue description

When using the ImageResizer with mode:crop, the crop() method never gets called.

Steps to replicate

Twig markup:

<img src="{{ 'image-path' | theme | resize(200, 100, {mode: 'crop'}) }}">

Plugin boot method:

Event::listen('system.resizer.processCrop', function ($resizer, $localTempPath) {
    trace_log("this won't show up");
});

Workaround

No response

@mjauvin mjauvin added Type: Unconfirmed Bug needs review Issues/PRs that require a review from a maintainer labels Aug 19, 2024
@bennothommo
Copy link
Member

@mjauvin I'm not sure that using mode: crop is synonymous with using the crop command in the ImageResizer class - it appears that crop is just a shortcut method. Further, it appears that the resize filter is passing everything through the resize method anyway, which just filters down to the Winter\Storm\Database\Attach\Resize utility class which does the actual resizing/cropping.

My guess is that the crop method was being set up to be used for a separate crop filter in Twig.

@LukeTowers
Copy link
Member

@mjauvin could you provide an example of what you were wanting to use the event for?

@mjauvin
Copy link
Member Author

mjauvin commented Aug 20, 2024

@LukeTowers I created a betterCrop() method that can crop from the different sides & corners of an image and I wanted to use the event for this.

@LukeTowers
Copy link
Member

@mjauvin so right now you're just using the resize event instead?

@mjauvin
Copy link
Member Author

mjauvin commented Aug 20, 2024

@mjauvin so right now you're just using the resize event instead?

Correct

@bennothommo bennothommo removed Type: Unconfirmed Bug needs review Issues/PRs that require a review from a maintainer labels Oct 3, 2024
@bennothommo
Copy link
Member

Let's close this off for now unless someone is able to confirm that using { mode: crop} doesn't actually crop the image (regardless of it being passed through to the resize() method.

@bennothommo bennothommo closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants