Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
fabpot merged 1 commit intosymfony:7.3frommaximecolin:valator-image-ratio-svg
Dec 29, 2024

Conversation

maximecolin
Copy link
Contributor

@maximecolinmaximecolin commentedDec 19, 2024
edited
Loading

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?no
IssuesFix#45269
LicenseMIT

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 withSIZE_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 usepreg_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.

matyo91 reacted with thumbs up emoji
@carsonbotcarsonbot added this to the7.3 milestoneDec 19, 2024
@maximecolinmaximecolinforce-pushed thevalator-image-ratio-svg branch 4 times, most recently from5f2304e to9e7ecc1CompareDecember 19, 2024 14:58
@maximecolin
Copy link
ContributorAuthor

Thanks@stof, I fixed the code according to your comments.

@maximecolinmaximecolinforce-pushed thevalator-image-ratio-svg branch 2 times, most recently from9281d5c to4b270ffCompareDecember 19, 2024 15:46
@maximecolinmaximecolinforce-pushed thevalator-image-ratio-svg branch 2 times, most recently from8726444 to1c16abfCompareDecember 23, 2024 08:33
@maximecolin
Copy link
ContributorAuthor

Thanks@OskarStark, I applied your suggestions.

@fabpotfabpotforce-pushed thevalator-image-ratio-svg branch from1c16abf toc4ad092CompareDecember 29, 2024 13:01
@fabpot
Copy link
Member

Thank you@maximecolin.

maximecolin reacted with heart emojichalasr reacted with rocket emoji

@fabpotfabpot merged commitb013b62 intosymfony:7.3Dec 29, 2024
5 of 11 checks passed
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestJan 2, 2025
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
@fabpotfabpot mentioned this pull requestMay 2, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@xabbuhxabbuhxabbuh left review comments

@fabpotfabpotfabpot approved these changes

@stofstofstof approved these changes

@OskarStarkOskarStarkAwaiting requested review from OskarStark

Assignees
No one assigned
Projects
None yet
Milestone
7.3
Development

Successfully merging this pull request may close these issues.

[Validator] Feat: Support SVGs when validating image dimensions
6 participants
@maximecolin@fabpot@stof@OskarStark@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp