#65944 closed defect (bug) (duplicate)
Toolbar: site icon renders at intrinsic size and does not replace the home dashicon
| Reported by: | fernandot | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Toolbar | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | ui, css |
Description
Since 7.1 the site icon is displayed in the toolbar. On several installations it is
not constrained to the intended size, and the home/odometer dashicon is still
rendered next to it instead of being replaced.
The visual result varies by installation, from a slightly oversized and blurry icon
to the full-size site icon painted over the page content on the front end. See the
attached screenshots.
Steps to reproduce
- Install WordPress 7.1 with a default theme and no plugins.
- Set a Site Icon in Settings > General.
- Log in and load the front end with the toolbar visible.
Expected behaviour
The site icon is rendered at 20x20 px with a border-radius of 2px, in place of the
home/odometer dashicon, as described in the changeset that closed #65088.
Actual behaviour
- The image is painted at the intrinsic size of the file returned by
get_site_icon_url()instead of 20x20 px. - The home/odometer dashicon is still rendered alongside the site icon, so the same site is represented twice in the same node.
Additional information
Reproduced on three installations. Two of them run the same theme and the
same plugin set and only one is affected, so this does not appear to be theme or
plugin dependent.
Value of get_site_icon_url( 32 ):
Adding max-width and max-height on the image restores the expected appearance,
which suggests the sizing rules are not reaching the element rather than the markup
being wrong.
Environment
- WordPress: 7.1
- Theme: Astra
- Browser: Chrome
- PHP: 8.2
Attachments (2)
Change History (12)
This ticket was mentioned in PR #13243 on WordPress/wordpress-develop by @iamchitti.
3 months ago
#2
- Keywords has-patch added; needs-patch removed
## Ticket
Trac ticket: https://core.trac.wordpress.org/ticket/65944
## Description
The site icon in admin-bar.css is sized only via width/height, so a theme/plugin img rule using !important overrides it and the icon renders at intrinsic size instead of 20x20 (28x28 on mobile).
Adds max-width/max-height alongside the existing rules so the size holds even when width/height are overridden.
## Testing
Set a Site Icon, then add img { width: auto !important; height: auto !important; } via Additional CSS — the icon should stay 20x20 with this fix (blows up without it).
## Screenshots
| Before | After |
|---|---|
| | |
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5
Used for: reproducing the bug locally.
#3
@
3 months ago
It should be noted that this issue affects not only site icons but also user avatars. Furthermore, styles for elements in the toolbar, not just images, can always be overridden by themes or plugins. This implies that the fundamental problem must have existed much earlier.
Personally, I am unsure whether this issue should be fixed in the core, because even if the core enforces styles, it is unavoidable that themes or plugins will override them.
#4
@
3 months ago
Related/duplicate: #65912
The min-width and max-width might help in some other cases, but the dashicon should not appear with the image. The old admin-bar CSS file could be cached, or another style rule might override the core stylesheet and include the icon.
#5
@
3 months ago
- Keywords has-screenshots has-patch removed
- Milestone 7.1.1
- Resolution → duplicate
- Status new → closed
- Version 7.1
As @sabernhardt noted, this is already being discussed in #65912. In order to keep the conversation organized, let's use the orignal ticket.
@adrianduffell commented on PR #13243:
2 months ago
#6
@i-am-chitti, thanks for contributing this PR. It is being considered for inclusion in the 7.1.1 release.
Could you please update the ticket in the description to https://core.trac.wordpress.org/ticket/65912, as the original ticket was marked as a duplicate.
@adamsilverstein commented on PR #13243:
2 months ago
#7
Please note the RC for 7.1.1 is September 10th if we want it included in that version. Otherwise it is fine to punt to 7.1.2.
@joedolson commented on PR #13243:
2 months ago
#8
I think that adding img.site-icon is helpful additional specificity, and the icon can only be an img element at this time, but adding !important creates a cascade effect where we need to add it everywhere. It would also make it harder for an extender to intentionally override the styles. I think that it's best to avoid adding !important unless it's absolutely necessary; it's only used in a handful of cases in core, and the majority of them are screen reader text classes, where the specific behavior is critical.
The specificity after adding img is 2, 2, 1, which is already a very high specificity.
I don't feel like adding min-height is super important, but also not harmful in that edge case.
While it is possible that this CSS won't capture every single case, I feel that the cases it *doesn't* catch are beyond what it makes sense for us to guard against.
@sabernhardt commented on PR #13243:
2 months ago
#9
Thanks for updating the branch.
However, I do not agree with the additional changes proposed above. People still should be able to override these dimensions intentionally.
- The CSS Coding Standards article encourages to "refrain from using over-qualified selectors."
#wpadminbar #wp-admin-bar-site-name > .ab-item .site-iconalready has a high specificity of2-2-0, and it is scoped to the Site Title link.- Increasing the selector specificity also affects anyone overriding properties related to
positionandborder-radius.
- WordPress admin styles avoid
!important(see Trac 47569 and Trac 26350). - If some CSS enforces a width or height smaller than 28 pixels, for _any_ image, I would expect that to cause bigger problems in other places.
@joedolson commented on PR #13243:
2 months ago
#10
The difference between 2,2,1 and 2,2,0 is pretty nominal to me; either are about equally difficult to override, should a user wish to. So as far as that change goes, I'm fine either way.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Moving for milestone 7.1.1 consideration.