Forum

Thread tagged as: Question, Problem, Error

SVG save Error

I get an error when I save my a file that has SVG images. My process:

  1. I delete the height and width information from my SVG files.
  2. I use CSS to size the svg images responsively.
  3. When I add the SVG image to the template it is showing as 0 x 0 in dimension but it is showing the correct file size.
  4. When I save the file I get two PHP errors
Warning: Division by zero in E:\wamp\www\testingServer3\_cms\core\lib\PerchImage.class.php on line 107

&

Warning: Cannot modify header information - headers already sent by (output started at E:\wamp\www\testingServer3\_cms\core\lib\PerchImage.class.php:114) in E:\wamp\www\testingServer3\_cms\core\lib\PerchUtil.class.php on line 1406 
  • Even though the errors appear the SVG's work on the page, I'm confident that the issue is that the SVG's are showing 0 x 0 dimensions because when I upload the same image files with PNG's everything works fine.
  • Is there a better way to work with SVG's in Perch. This is probably due to my ignorance but I was just thinking someone may have run into the same issue.
Matt Holovach

Matt Holovach 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you need to delete the default dimensions?

Maybe I don't need to delete the default dimensions? The way my SVG files are output there is a width and height included in the SVG XML file and it seems like when I leave those default dimensions in the file they overwrite my CSS.

The SVG file always has a height and width dimension in points. I want the dimensions to be responsive so I believe I need to remove them from the file or possibly I can change them directly in the file? The problem is I don't know what to change the dimensions too.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I see you're on Windows - I wonder if that's the problem here. We attempt to detect SVG files uploaded as images (obviously they're text files, not images, but are treated as images conceptually). That could be failing in your environment.

Do you have the finfo extension installed? If not, could you try it?

Drew,

Yes I'm definitely on Windows. The fileinfo option in my PHP extensions was already on. In the end I'm not going to let customers upload SVG files, this was my personal website and I was tinkering with it as a workflow for me mainly, but I could still leave the SVG files outside the Perch resources bucket and just call them through Layouts so it isn't the end of the world. Also, everything ends up working even with the error messages.

Below is the PHP error log

[08-Oct-2017 16:23:13 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at E:\wamp\www\testingServer3\_cms\core\lib\PerchImage.class.php:114) in E:\wamp\www\testingServer3\_cms\core\lib\PerchUtil.class.php on line 1413

[08-Oct-2017 16:23:13 UTC] PHP Stack trace:

[08-Oct-2017 16:23:13 UTC] PHP   1. {main}() E:\wamp\www\testingServer3\_cms\core\apps\content\edit\index.php:0

[08-Oct-2017 16:23:13 UTC] PHP   2. include() E:\wamp\www\testingServer3\_cms\core\apps\content\edit\index.php:24

[08-Oct-2017 16:23:13 UTC] PHP   3. PerchUtil::set_security_headers() E:\wamp\www\testingServer3\_cms\core\inc\top.php:4

[08-Oct-2017 16:23:13 UTC] PHP   4. header_remove() E:\wamp\www\testingServer3\_cms\core\lib\PerchUtil.class.php:1413
Drew McLellan

Drew McLellan 2638 points
Perch Support

When/where do those errors occur? Is this the same issue?

Yes this is the exact same issue, but this is the php error log. The original error in my first post is what was showing up in the CMS when I pressed Save. I was hoping that the error messages might help you in debugging at some point. Thanks Drew.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think that error is just a result of the first error displaying on the page.

Yes I'm sure it is. I was just giving you as much info as possible on the issue.

Dear Drew and Matt,

It's interesting, but today I'm having exactly the same problem with Perch. When I upload an svg file, it seems to be working on the site itself, but throws the 'Warning: Division by zero...' error above in the admin.

The svgs I'm trying to upload doesn't have height and width properties embedded, but are stylized by css. As they're the 'raw' files from the 'Icon54' icon set, I don't want to manually add these lines to about 5.000 of them. Is there a good Perch workaround for this – so that I can use these svgs as they are?

I'm on Windows too – I don't know if it matters.

Thank you in advance, Márton Lente