Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Validator] Validate SVG ratio in Image validator#59265
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
5f2304e
to9e7ecc1
CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
9e7ecc1
tocef5a7b
CompareThanks@stof, I fixed the code according to your comments. |
Uh oh!
There was an error while loading.Please reload this page.
9281d5c
to4b270ff
CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
8726444
to1c16abf
CompareThanks@OskarStark, I applied your suggestions. |
Uh oh!
There was an error while loading.Please reload this page.
1c16abf
toc4ad092
CompareThank you@maximecolin. |
b013b62
intosymfony:7.3Uh oh!
There was an error while loading.Please reload this page.
This PR was merged into the 6.4 branch.Discussion----------[Validator] Cannot validate svg image sizeAs an addition of#20496 and considering what is described in related [code PR](symfony/symfony#59265) I think it can be helpful to explicit mention this restriction for SVG imagesCommits-------248d4ff cannot validate svg image size
Uh oh!
There was an error while loading.Please reload this page.
Implement ratio check for SVG images. Checking SGV size is not relevant as a SVG image can be enlarged without loss, but ratio can be important to check.
Currently, the validator add a violation with
SIZE_NOT_DETECTED_ERROR
in case of SVG image.SVG size is guessed from viewbox, width and height attributes. Viewbox will provides default size, width and height can override viewbox size if they are number. Width and height as percentage are ignored as the final size will depend on the container.
I use
preg_match
instead of\DomDocument
orsimplexml
functions to extract viewBox, width and height in order to avoid new dependencies onext-dom
orext-simplexml
.In case of SVG,
minWidth
,maxWidth
,minHeight
,maxHeight
,minPixels
andmaxPixels
are ignored because not relevant. OnlymaxRatio
,minRatio
,allowSquare
,allowLandscape
andallowPortrait
can generate violations, like suggested in the comments of the abandoned#45486.