Skip to content

[Validator] Feat: Support SVGs when validating image dimensions #45269

@silverbackdan

Description

@silverbackdan

Description

If any image dimension validation is added with Image validation, it will fail with SVGs as the image size is detected using getimagesize. See: https://github.com/symfony/validator/blob/5.4/Constraints/ImageValidator.php#L56

Would there be a want from the community if I were to create a PR to detect SVG images and grab the file size from the XML? With this, we could skip the width/height validation all together, but still be able to implement features such as portrait/landscape/ratio validation.

I guess with the mime type, I could work out that it is an SVG, parse the content, and skip the width/size validation (it shouldn't matter with SVGs really.. or I could add an option?) I could implement other dimension validation still and return the same error if we still cannot detect the image size.

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions