When checking mime type of SVG files, be forgiving if they lack an XML declaration #2837
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When trying to read SVG files to pass through the svg() TWIG function, if they lack a XML declaration, they are not read as
FileHelper::isSvg
returns false.Given the comment in
FileHelper::getMimeType
, this seemed like the appropriate place to make the change. Otherwise, you could allow 'image/svg' in the FileHelper::isSvg.Either way, this allows you to reference local SVG files that lack an XML declaration.
To reproduce:
{{ svg(icon.folder.volume.path ~ "/" ~ icon.filename) }}
Note: this is an icon from Font-Awesome Pro, so adding XML declarations to all of the 800+ files is not practical. Given the comment in FileHelper::getMimeType, it seems that was supposed to cover SVG files anyway.