-
Notifications
You must be signed in to change notification settings - Fork 79
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow SVGs to be handled as regular images #1452
Comments
This bit of YML gets you part of the way there SilverStripe\Assets\File:
allowed_extensions:
- svg
app_categories:
image:
- svg
image/supported:
- svg
class_for_file_extension:
svg: SilverStripe\Assets\Image Thumbnails don't work, but you can get the SVG in a WYSIWYG. |
We could easily update the The bigger problem is image manipulation methods... if you have a relation to |
Yeah ... image manipulation is the biggest question in my mind. I'm not sure we want to create a I'm thinking maybe we just update the image picker logic in the WYSIWYG so you can pick something that isn't an |
That sounds like a can of worms that I don't think we want to open tbh. Images should be images. If we're not treating SVG as an image, it shouldn't be selectable as an image. |
Wouldn't it be possible to intercept the image manipulation methods so that they all just always return the original svg? It's really most of the time not the desired effect to get a rasterized svg and my acceptance criteria for an SVG-Image is "does not break". Not "works just like a raster image" ;-) |
Yes, but:
This isn't to say we absolutely won't go down that route, just pointing out potential problems if we choose to do so. |
Us developers can argue about how the system should handle SVGs internally, whether you should rasterise them or whether they should be resizable. But I think the average content author won't give a toss about all of this. The end goal of an SVG is to display something that my eye balls can see. From the end user's perspective, that's an image. |
Text is an image by that definition :p Right now everything we say is an "image" works the same way in both of those contexts, so developers don't have to account for any differences. Adding svg to our definition of "image" would change how developers have to think about their usage and treatment of images. |
To the extent that you have to install a third party module to get SVG support, I think it's fair to put it back on the developer installing the module to make sure that anywhere they expect an Image, they can account for the possibility that they will get an SVG. On the "Insert an Image in WYSIWYG" front, the only concern we would have to consider is "how do we handle the resize of the SVG?". That could be handled by serving you the same SVG file no matter what, and relying on the I think that's the bit that stop you form inserting non-image as image in the WYSIWYG. silverstripe-asset-admin/code/Forms/FileFormFactory.php Lines 45 to 49 in a995132
We could just stick a bit in there to make this configurable. Looking back at the ACs:
Maybe it becomes:
The rest of the ACs will be the responsibility of the third party who is implementing the actual SVG support.
|
Couldn't the |
We've historically not allowed SVGs to be uploaded in the CMS because they can contain XSS payload. We had an RFC back in the day about adding full SVG support. We opted against it mostly for security reason.
Security rational is still valid. However they are some SVG good sanitizers that can be used to mitigate the risk. And many developers are choosing to wear the risk of using SVG to provide a better experience for their users:
In this context, we could update asset-admin so that SVG images can be handled as regular images in the CMS ... if developers choose to add them to the list of allowed file extensions.
User story
As a content author, I want to be able to use SVG images in the CMS transparently if my project owner is willing to accept the risk.
Acceptance criteria
Note
Image
and whether you should be able to rasterise them. That still seems relevant today.The text was updated successfully, but these errors were encountered: