Make WordPress Core

#64346 closed defect (bug) (invalid)

SVG Image dimensions overwritten to hardcoded 24 pixels

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

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 12 months 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 12 months ago.
The correct SVG dimensions
Screenshot 2025-12-04 at 2.31.35 AM.png​ (777.8 KB ) - added by ajayadav09 12 months ago.
the svg image dimension is incorrectly set to 24px

Download all attachments as: .zip

Change History (7)

#1 @sabernhardt
12 months 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
12 months 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
11 months ago

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

#4 @sabernhardt
11 months ago

  • Keywords close removed
  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → 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.