Make WordPress Core

Opened 10 days ago

Closed 7 days ago

#64346 closed defect (bug) (invalid)

SVG Image dimensions overwritten to hardcoded 24 pixels

Reported by: ajayadav09's profile ajayadav09 Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.9
Component: Media Keywords:
Focuses: Cc:

Description (last modified by sabernhardt)

I have an SVG image in my <Button /> component from wordpress/components as an icon. Once the version updated to 9. The dimension of the svg image which is originally 160 X 50 changed to 24px in width and height. This was supposedly introduced by the changes here for #63714.

I have added the images in the comments on the commit too.

Attachments (3)

Screenshot 2025-12-04 at 2.54.47 AM.png (337.6 KB) - added by ajayadav09 10 days ago.
React Code where I am including the file
Screenshot 2025-12-04 at 2.33.14 AM.png (335.7 KB) - added by ajayadav09 10 days ago.
The correct SVG dimensions
Screenshot 2025-12-04 at 2.31.35 AM.png (777.8 KB) - added by ajayadav09 10 days ago.
the svg image dimension is incorrectly set to 24px

Download all attachments as: .zip

Change History (7)

@ajayadav09
10 days ago

React Code where I am including the file

@ajayadav09
10 days ago

The correct SVG dimensions

@ajayadav09
10 days ago

the svg image dimension is incorrectly set to 24px

#1 @sabernhardt
10 days ago

  • Description modified (diff)

Hi and welcome to WordPress Core Trac!

I do not think that this would relate to ticket #63714. It edited the wp_get_attachment_image() function, and the ns.svg plugin resource is not an attachment.

This might be one of the cases of GB70756 changing the old output of the Icon component, but I would appreciate someone else checking that (because I do not know the wordpress/components package well).

#2 @westonruter
9 days ago

  • Keywords close added

This is probably something that would be better reported to the Gutenberg repo, because that's where this package is maintained.

In any case, take a look at the docs for the Icon component: https://github.com/WordPress/gutenberg/tree/trunk/packages/components/src/icon

The size prop's default value is defined as:

Defaults to 20 when icon is a string (i.e. a Dashicon id), otherwise 24.

Since you're passing in a component, it makes sense that you'd be seeing a size of 24x24.

In other words, it does not read the size from the SVG. You'll need to supply the size yourself.

#3 @ajayadav09
7 days ago

@westonruter thank you. I will update my code to not include as icon.

#4 @sabernhardt
7 days ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Thanks for following up. Then I'll close the ticket (as 'invalid' because it is not a core bug).

Note: See TracTickets for help on using tickets.