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

Add CropResizer #1940

Merged
merged 1 commit into from
Mar 19, 2021
Merged

Add CropResizer #1940

merged 1 commit into from
Mar 19, 2021

Conversation

core23
Copy link
Member

@core23 core23 commented Mar 18, 2021

Subject

Adds a new resizer that is similar to the existing SquareResizer, but the result can have any image ratio.

The new resizer can crop the Image to a given ratio. When given an Image with 1200 x 700 and you want an image with the format 100 x 70, the resizer will first scale the image down to 120 x 70 and then crops the remaining parts down to 100 x 70.

I am targeting this branch, because this feature is BC.

Changelog

### Added
- Added `CropResizer`

@core23 core23 added the feature label Mar 18, 2021
@core23 core23 requested a review from a team March 18, 2021 19:33
src/Resizer/CropResizer.php Outdated Show resolved Hide resolved
src/Resizer/CropResizer.php Outdated Show resolved Hide resolved
src/Resizer/CropResizer.php Outdated Show resolved Hide resolved
src/Resizer/CropResizer.php Outdated Show resolved Hide resolved
src/Resizer/CropResizer.php Outdated Show resolved Hide resolved
tests/Resizer/CropResizerTest.php Outdated Show resolved Hide resolved
tests/Resizer/CropResizerTest.php Outdated Show resolved Hide resolved
tests/Resizer/CropResizerTest.php Outdated Show resolved Hide resolved
@core23 core23 force-pushed the crop-resizer branch 2 times, most recently from e3e8e8e to dafb5d2 Compare March 18, 2021 21:43
src/Resizer/CropResizer.php Outdated Show resolved Hide resolved
src/Resizer/CropResizer.php Outdated Show resolved Hide resolved
tests/Resizer/CropResizerTest.php Outdated Show resolved Hide resolved
tests/Resizer/CropResizerTest.php Outdated Show resolved Hide resolved
@jordisala1991
Copy link
Member

Can you add some docs on how to use this new feature?

@core23
Copy link
Member Author

core23 commented Mar 19, 2021

Can you add some docs on how to use this new feature?

Done

@phansys phansys requested review from VincentLanglet and a team March 19, 2021 10:00
Copy link
Member

@wbloszyk wbloszyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can merge this PR. My comments are only suggestion how we can improve it.

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="sonata.media.resizer.crop.class">Sonata\MediaBundle\Resizer\CropResizer</parameter>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO Will be nice to remove these parameters from xml and move it to the bundle configurator.

new Reference('sonata.media.metadata.proxy'),
]);
$definition->addTag('sonata.media.resizer');
$container->setDefinition('sonata.media.resizer.crop', $definition);
Copy link
Member

@wbloszyk wbloszyk Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create sonata.media.resizer.base_crop for default class and sonata.media.resizer.crop alias for service or class configured by users?

@core23 core23 merged commit 9353e2f into sonata-project:3.x Mar 19, 2021
@core23 core23 deleted the crop-resizer branch March 19, 2021 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants