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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we be certain that svg files always have
.svg
at the end of their sources in WP?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevin940726 I believe in the context of the image block, yes. I was researching, and the other option is the
.svgz
extension, which is for compressed SVGs. I never saw any, but we could add it, to make it more robust and cover all cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm mostly concerned that SVG files don't have to end with the
.svg
postfix in the URLs. Browsers look for the content types, not the file extensions. I'm not sure if this applies to this case though!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's not certain but highly likely. So if this fixes for 80% of sites then it's an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true, but I believe it doesn't apply to this case, where the SVG is uploaded via UI and inserted via image block. If I'm not mistaken, the media library/image block should insert images with their file extensions.
The problem would be if a block themer, includes an image block on some pattern or template, where the image src uses
data:image/...
, and if the image doesn't have dimensions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, I agree! I think this is a good improvement even though I have some minor concerns. I think we can merge this and iterate if necessary.
Would someone be able to insert an SVG file via an external URL? I'm not too familiar with the media upload module, but could someone upload an SVG file without the extension? That is, does the code look for the MIME type or the file extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, not via UI using the medialibrary.