Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove PX from Height and Width in SVG files #127

Open
1 task done
lgdelai opened this issue May 9, 2023 · 0 comments
Open
1 task done

Remove PX from Height and Width in SVG files #127

lgdelai opened this issue May 9, 2023 · 0 comments
Labels
help wanted Extra attention is needed type:enhancement New feature or request.

Comments

@lgdelai
Copy link

lgdelai commented May 9, 2023

Is your enhancement related to a problem? Please describe.

Hello.

First of all, congratulations on the great work done with your plugin and the support provided here.

See, I noticed an error on my test site, and after some research I found that it might be something to do with how the SVG file is exported.

First I’ll talk about the error:

When I activate these 3 options in the wp-config file:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );

And with the active MENU+ feature on GeneratePress plugin

I get this error at the top of my website.

Notice : Undefined index: width in
/home/cp04u/public_html/domain.com/wp-content/plugins/gp-premium/menu-plus/functions/generate-menu-plus.php
on line
2200

Notice : Undefined index: height in
/home/cp04u/public_html/domain.com/wp-content/plugins/gp-premium/menu-plus/functions/generate-menu-plus.php
on line
2201

I create SVG files using CorelDraw, after creating I export, and the files created by CorelDraw contain in their code the PX text right after the Height and Width dimensions.

And it seems that this causes the error, because after I edit the SVG file in notepad, removing the PX, the error disappears.

I contacted the developers, and they told me this:

Its actually the limitations in WordPress not supporting SVG by default.
GP uses core WordPress functions to handle the site logos.
One of those functions is
this: wp_get_attachment_metadata
https://developer.wordpress.org/reference/functions/wp_get_attachment_metadata/

And it expects the width and height of the attachment to be an integer. Which is standard for a img attachment.
If CorelDraw insists on adding px to those attributes then run the SVG through this optimizer:
https://jakearchibald.github.io/svgomg/
That should remove them and clean up the SVG

Designs

No response

Describe alternatives you've considered

It would be much better if Safe SVG already made this correction, don’t you think?

Thanks.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@lgdelai lgdelai added the type:enhancement New feature or request. label May 9, 2023
@jeffpaul jeffpaul added this to the 2.2.0 milestone Jun 29, 2023
@dkotter dkotter modified the milestones: 2.2.0, 2.3.0 Jul 3, 2023
@jeffpaul jeffpaul added the help wanted Extra attention is needed label Jan 16, 2024
@jeffpaul jeffpaul modified the milestones: 2.3.0, Future Release Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed type:enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

3 participants