Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Invalid SVG?
Bloke wrote #340859:
Viewbox stuff needs looking at. And yes the checks for top/left > 0 would make sense here.
top
and left
in the viewBox attr. can be negative, it is a <number>
The MDN article has examples with negative top
and left
coordinates. The width
and height
must be greater than 0.
We could be a little less opinionated on case, perhaps? So we accept nothing forms of viewBox or viewBox? Or does the spec mandate one or the other?
The case sensitivity of the viewbox/viewBox attribute is unclear. The origin of SVG is XML – case sensitive, bu that has been relaxed it seems, but is kept for backwards compatibility. Current browsers can display my SVG file with lowercase viewBox correctly (incl. the now quite old Safari 15.7).
PS – all SVG I use online only specify the viewbox attribute, never specify width and height. Those upload just fine and are correctly managed (thumbnail generation wise)
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: Invalid SVG?
phiw13 wrote #340861:
top
andleft
in the viewBox attr. can be negative… Thewidth
andheight
must be greater than 0.
Ah okay. Worth knowing, thank you.
all SVG I use online only specify the viewbox attribute, never specify width and height. Those upload just fine and are correctly managed (thumbnail generation wise)
Interesting. Wonder why my ones failed then. Hmmm…
p.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Invalid SVG?
Maybe a bit late, but I find svgomg very useful in prepping svgs.
Offline
Re: Invalid SVG?
Bloke wrote #340862:
Interesting. Wonder why my ones failed then. Hmmm…
Your Lexmark file “failed” because the non-zero top & left coordinates in the viewBox (viewBox="79 199 1000 198.3"
). Current Textpattern code doesn’t seem to like that. (all the SVG files I actually use in Textpattern context always have zero top & left coordinates.)
Is that requirement for zero top & left coordinates a kind of security or validation check before upload?
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
#17 Today 06:37:25
Re: Invalid SVG?
phiw13 wrote #340864:
Your Lexmark file “failed” because the non-zero top & left coordinates in the viewBox (
viewBox="79 199 1000 198.3"
). Current Textpattern code doesn’t seem to like that. (all the SVG files I actually use in Textpattern context always have zero top & left coordinates.)Is that requirement for zero top & left coordinates a kind of security or validation check before upload?
I don’t think it does stipulate that. It’s the width and height that must be greater than zero, but – as I wrote above – because the calculation method is wrong, this line calculates the height as 198.3 – 199 = -0.7
and throws it out because the height is negative.
Unless I’ve misunderstood it completely, I think that calculation definitely needs correcting as it’s a bug. I can try – also later in the week – to make a PR for that and the unit conversion.
TXP Builders – finely-crafted code, design and txp
Offline
#18 Today 07:41:13
Re: Invalid SVG?
Yeah, I was partly confused by that file, as I hacked it to set the viewBox coordinates to 0 0
and that allowed the file to upload.
There is no limit (in Textpattern code) on the top
and left
coordinates – afterwards I tested with positive and negative values on (simple) test files and all uploaded correctly.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
#19 Today 09:19:23
Re: Invalid SVG?
Ah, that makes sense. So yes the viewBox calculation looks likely the culprit. Great sleuthing, thank you.
This is all a bit beyond me, but I went through those excellent Josh Comeau articles on SVG and learnt a load, thank you. I never realised how insanely capable and manipulable SVG are. It’s given me some ideas!
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline