Skip to content

Conversation

alexander-schranz
Copy link
Contributor

@alexander-schranz alexander-schranz commented Jan 27, 2022

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #...
License MIT
Doc PR symfony/symfony-docs#...

Currently the generated ratio get rounded to 1.33 but the inputted ration not. This can end into a strange behaviour when working with example:

new Image([
    'maxRatio' => 64 / 48,
    'minRatio' => 64 / 48,
]),

Workaround currently required rounding input value itself:

new Image([
    // round ratio the same way as the validator: https://github.com/symfony/symfony/blob/4834d9e224b97f946fe8e13b2ba403bbc212c4ad/src/Symfony/Component/Validator/Constraints/ImageValidator.php#L165
    'maxRatio' => round(64 / 48, 2),
    'minRatio' => round(64 / 48, 2),
]),

Another solution would be removed:

-   $ratio = round($width / $height, 2);

instead. What do you think?

@nicolas-grekas
Copy link
Member

Needs tests :)

@alexander-schranz
Copy link
Contributor Author

@nicolas-grekas added :)

@fancyweb
Copy link
Contributor

Thank you @alexander-schranz.

@fancyweb fancyweb merged commit 19da12f into symfony:4.4 Jan 31, 2022
@alexander-schranz alexander-schranz deleted the patch-10 branch January 31, 2022 09:25
This was referenced Feb 28, 2022
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