Add Width and Height to UmbracoMediaVectorGraphics (SVG) #22114
Replies: 7 comments 6 replies
-
|
Yes, please! |
Beta Was this translation helpful? Give feedback.
-
|
Please feel free to bring a PR @enkelmedia, we'd be happy to consider it. The only thing I wonder is that it would need to be clearly applicable for all projects and all SVGs to make sense in core. For example I understand an SVG can use units like |
Beta Was this translation helpful? Give feedback.
-
|
@AndyButland nice that you think that this might make sense! You are right in that My understanding is that in a SVG like this: <svg width="800px" height="800px" viewBox="0 0 36 36" ..../>The So at the end of the day there is really no bullet proof way to get "pixels" from a SVG, but I think for the vast majority of cases something like this would be sufficient:
Would this make sense? |
Beta Was this translation helpful? Give feedback.
-
|
I was wondering if maybe @AndyButland could help me out with some pointers so that I create the PR in the desired way. Question 1I'm not sure if I'm on the right path but my initial idea was to look at It uses The interface is quite simple One approach could be to use this interface, maybe allow multiple implementations ( But. I'm not sure if we should think about "SVGs" as "Images", that's maybe the philosophical questions here. What do you think? Should I approach this in another way? Question 2I've been thinking about when/how to add the I guess it comes down to should they only be added to fresh installs or should we append them during a upgrade? |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for the pointers @AndyButland! I've worked on this for a while now and I have:
I have have a couple of more questions to ensure that I'm doing the right thing. As far as I understand, the migration will run both for a new install and a existing install. I guess that this would be sufficient to ensure that them to "be added in a migration as well as for new installs"? When looking at how the Now, I'm wondering which road to take here, should I:
|
Beta Was this translation helpful? Give feedback.
-
|
I went ahead and implemented a separate Notification Handler in my first draft PR, of course happy to change based on feedback. Here's the PR |
Beta Was this translation helpful? Give feedback.
-
|
This has been completed now via #22244, thanks @enkelmedia for the suggestion and the implementation. Will be part of 17.4. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We just had the need to provide a aspect ratio for a UmbracoMediaVectorGraphics (SVG). I solved this by adding
umbracoWidthandumbracoHeightto the built in Media Type and added aMediaSavingNotificationHandlerthat parses the XML of the SVG to get the width and height from either width/height attributes or theviewbox.That got me thinking that maybe this could be a nice addition to the core?
Would be happy to contribute the code in a PR if this is something that we want.
Beta Was this translation helpful? Give feedback.
All reactions