Jump to content
rick

[resolved] Error trying to load SVG

Recommended Posts

I have an image field with SVG as one of the allowed file types. However, when I try to upload an SVG image in page edit, I get the following error:

Error
Call to undefined function ProcessWire\simplexml_load_string()

File: .../www/cre8aplace/wire/core/Pageimage.php:533

523:         * @return array of width and height
524:         *
525:         */
526:        protected function getImageInfoSVG($filename = '') {
527:            $width = 0;
528:            $height = 0;
529:            if(!$filename) $filename = $this->filename;
530:            $xml = @file_get_contents($filename);
531:            
532:            if($xml) {
533:                $a = @simplexml_load_string($xml)->attributes();
534:                if((int) $a->width > 0) $width = (int) $a->width;
535:                if((int) $a->height > 0) $height = (int) $a->height;
536:            }
537:            

Other image types load fine. I haven't seen a post relating to this issue, so I assume it's pilot error again. 🙂

Is there some special field setting I have missed or is this an actual bug?

Is it a continuation of the git issue regarding dimension attributes?

<svg id="e532202f-8294-4472-8a94-ef01c23bf434" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1111.01" height="589.53" viewBox="0 0 1111.01 589.53">

There is no attributes section in the file. The dimensions are included in the header as shown.

 

Edited by rick
id10t

Share this post


Link to post
Share on other sites

@rick - Actually, sorry I didn't read properly - the issue is that you don't have the "php-xml" PHP module installed.

  • Like 1

Share this post


Link to post
Share on other sites

Dagnabit!

^ My best Walter Brennan impression.

  • Like 1

Share this post


Link to post
Share on other sites
6 minutes ago, rick said:

Dagnabit!

^ My best Walter Brennan impression.

Wow, you're going back in time there 🙂

I remember my parents talking about him, and I am sure I saw a few of his movies in my youth (they liked a good western), but don't honestly remember that expression.

  • Like 1

Share this post


Link to post
Share on other sites

walter-brennan.jpg.6a675594f115ebc3a69f6df03987caa7.jpg

I'm an old fart. Thanks for reminding me. 😂

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...