Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 Yesterday 09:44:32

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,482
Website

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

#14 Yesterday 11:14:06

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,999
Website GitHub

Re: Invalid SVG?

phiw13 wrote #340861:

top and left in the viewBox attr. can be negative… The width and height 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

#15 Yesterday 18:16:29

giz
Plugin Author
From: New Zealand
Registered: 2004-07-26
Posts: 391
Website GitHub Twitter

Re: Invalid SVG?

Maybe a bit late, but I find svgomg very useful in prepping svgs.

Offline

#16 Yesterday 22:38:44

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,482
Website

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

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,035
Website GitHub

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

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,482
Website

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,999
Website GitHub

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

Board footer

Powered by FluxBB