Make WordPress Core

Opened 8 weeks ago

Closed 2 weeks ago

Last modified 13 days ago

#65912 closed defect (bug) (fixed)

wordpress 7.1 broke site icon

Reported by: donniam Owned by: adrianduffell
Priority: high Milestone: 7.1.3
Component: Toolbar Version: 7.1
Severity: major Keywords: has-screenshots has-patch commit
Cc: Focuses:

Description

I updated wp 7.1 and it blew my site icon up. Please find a fix. i would do a roll back but having problems with my back up co. logging in

Attachments (2)

71-big-site-icon.jpg​ (134.3 KB ) - added by kgagne 8 weeks ago.
Site icon in admin toolbar 7.1
site-icon-error.png​ (33.4 KB ) - added by webverts 6 weeks ago.

Download all attachments as: .zip

Change History (43)

#1 @desrosj
8 weeks ago

  • Milestone 7.1

Ticket retargeted after milestone closed

#2 @desrosj
8 weeks ago

  • Milestone → 7.1.1
  • Version → 7.1

Hi @donniam!

Apologies, but this is not enough information to investigate this issue. Are you able to share any messages in the site's error log?

This ticket was mentioned in ​Slack in #core by desrosj. ​View the logs.


8 weeks ago

#4 @jorbin
8 weeks ago

In addition to checking your error logs, are you able to share what your site icon was set to before, how you had set it, and what happened after you upgraded

#5 @donniam
8 weeks ago

Hi thanks for replying. how do i find the error logs. i have been having severe cognative issues for a couple of years and have a hard time remembering things. I only updated a few sites and was able to remove the site icon. it has happened on divi and gem theme. those are the only ones i updated. no i cannot figure it out on the backend. i wanted to send a phtot screenshot but i do not see an area. I can't imagine i am the only one. I am not going to update anymore sites. i want to add image and it does not allow me to. No image "[[Image([[Image([[Image(" attached to Ticket #65912)]])]])]]

#6 @donniam
8 weeks ago

my site icons have always been uploaded through the appeaance identity area and have always been fine until 7.1. i will drop my backup company after this because the one time i needed them they would not let me login. going with muy hosting company. i can ask them tomorrow. hopefully you will have other complaints and have a update for this. they were all fine before update. i removed the site icons

@kgagne
8 weeks ago

Site icon in admin toolbar 7.1

#7 follow-up: @kgagne
8 weeks ago

This happened on my Pressable site; a screenshot is attached above.

It might be a caching issue, but in the meantime, I fixed it with this CSS in the theme customizer:

#wpadminbar .site-icon {
    width: 20px !important;
    height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
}

#8 follow-up: @khokansardar
8 weeks ago

Diagnosis

The oversized icon appears when a site is served a pre-7.1 copy of admin-bar.css alongside 7.1's markup — an asset-cache skew. Core makes that skew catastrophic rather than cosmetic, for two reasons.

1. The width/height attributes on the new image cannot constrain its rendered size.

[62625] renders:

<img class="site-icon" src="..." alt="" width="20" height="20" />

Those attributes are presentational hints. They still supply the intrinsic aspect ratio, but they cannot set the rendered size, because admin-bar.css has long overridden both properties for every admin bar descendant:

#wpadminbar * {
      height: auto;
      width: auto;
      ...
}

So the image is sized only by the rule [62625] added. If that single rule doesn't reach the browser, there is no fallback and the image renders at its intrinsic size.

Verified on trunk (Twenty Twenty-One, front end): deleting just the .site-icon rules from the loaded stylesheet via CSSOM changes the render from 20x20 to 150x150 — overflowing 118px below the 32px bar — and brings the \f226 dashicon back. The screenshot in this ticket shows both the dashicon and the oversized icon, which is only possible when the .has-site-icon rules are not applied.

2. get_site_icon_url( 32 ) does not necessarily return a 32px file.

When the site_icon-32 crop is missing, it falls back to the smallest available intermediate, or to the full-size file. In testing that returned a 150x150 thumbnail in one case and the original upload in another. The ~280px icon in the screenshot is consistent with site_icon-270.

Suggested next step for reporters

@donniam, @kgagne — in the page source, could you check the ver query argument on the admin-bar.css/admin-bar.min.css link? If it reads lower than 7.1, the stylesheet is being served from cache and a cache purge should resolve the display. That would also confirm the mechanism above.

#9 follow-up: @kgagne
8 weeks ago

I had the plugin ​WP Remove Query Strings From Static Resources activated, which meant there was no ver query argument. However, I can confirm that the 7.1 version of the stylesheet is now loading (with or without the plugin), and the custom CSS I previously provided is no longer needed.

#10 in reply to: ↑ 9 @khokansardar
8 weeks ago

Replying to kgagne:

I had the plugin ​WP Remove Query Strings From Static Resources activated, which meant there was no ver query argument. However, I can confirm that the 7.1 version of the stylesheet is now loading (with or without the plugin), and the custom CSS I previously provided is no longer needed.

Thanks @kgagne — that confirms it. Removing the ver query argument defeats core's cache busting, so the browser kept serving the pre-7.1 admin-bar.css against 7.1's markup, which is the skew described in comment:8. The released 7.1 stylesheets (both LTR and RTL) do contain the .site-icon rules, so there is nothing broken in core here.

@desrosj — I'd suggest closing this as worksforme, unless @donniam is able to reproduce it with a current copy of admin-bar.css loading.

#11 in reply to: ↑ 7 @donniam
8 weeks ago

Replying to kgagne: that css worked. I am sure this may need adjustment later but thank you.

This happened on my Pressable site; a screenshot is attached above.

It might be a caching issue, but in the meantime, I fixed it with this CSS in the theme customizer:

#wpadminbar .site-icon {
    width: 20px !important;
    height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
}

#12 in reply to: ↑ 8 @donniam
8 weeks ago

Replying to khokansardar:Thanks for the detailed message. This may be a bit deep for me. I am not sure how to do this. I am using suggested css for now that kgagne suggested. I have to look at this when i have more time. I have been dealing with a cognative issue for quite some time and focus is hard.

Diagnosis

The oversized icon appears when a site is served a pre-7.1 copy of admin-bar.css alongside 7.1's markup — an asset-cache skew. Core makes that skew catastrophic rather than cosmetic, for two reasons.

1. The width/height attributes on the new image cannot constrain its rendered size.

[62625] renders:

<img class="site-icon" src="..." alt="" width="20" height="20" />

Those attributes are presentational hints. They still supply the intrinsic aspect ratio, but they cannot set the rendered size, because admin-bar.css has long overridden both properties for every admin bar descendant:

#wpadminbar * {
      height: auto;
      width: auto;
      ...
}

So the image is sized only by the rule [62625] added. If that single rule doesn't reach the browser, there is no fallback and the image renders at its intrinsic size.

Verified on trunk (Twenty Twenty-One, front end): deleting just the .site-icon rules from the loaded stylesheet via CSSOM changes the render from 20x20 to 150x150 — overflowing 118px below the 32px bar — and brings the \f226 dashicon back. The screenshot in this ticket shows both the dashicon and the oversized icon, which is only possible when the .has-site-icon rules are not applied.

2. get_site_icon_url( 32 ) does not necessarily return a 32px file.

When the site_icon-32 crop is missing, it falls back to the smallest available intermediate, or to the full-size file. In testing that returned a 150x150 thumbnail in one case and the original upload in another. The ~280px icon in the screenshot is consistent with site_icon-270.

Suggested next step for reporters

@donniam, @kgagne — in the page source, could you check the ver query argument on the admin-bar.css/admin-bar.min.css link? If it reads lower than 7.1, the stylesheet is being served from cache and a cache purge should resolve the display. That would also confirm the mechanism above.

#13 @wildworks
7 weeks ago

The symptoms reported here appear to be similar to those reported in #65944.

#14 @sabernhardt
7 weeks ago

  • Component General → Toolbar

#16 @dyin
7 weeks ago

just wanted to say two things after testing it:
1) on mobile when signed it on the admin account the site logo isn't even contained in the box where it should be. It is floating to the rights and partly invisible
2) my logo has a white background in the admin dash. This is rather ugly as the admin bar is black. So I would guess the background should be transparant.

#17 @jorbin
7 weeks ago

#65944 was marked as a duplicate.

#18 follow-up: @jorbin
7 weeks ago

For people that are seeing a larger than expected icon, can you please check:

1) When the admin bar is loaded on the front end, ​https://<your-site>/wp-includes/css/admin-bar.min.css?ver=7.1 is also loaded?
2) In that file, there is a #wpadminbar #wp-admin-bar-site-name>.ab-item .site-icon rule that includes a width and height instruction?
3) If you use the inspector, do you see any rules applying on the img.site-icon file from other sources such as those from a theme or plugin?

Additionally, do you see this issue with all of your plugins disabled and using a default theme?

#19 @minosh
7 weeks ago

Clearing both the WordPress cache and my browser cache solved this for me. After clearing both, the issue disappeared completely.

#20 in reply to: ↑ 18 @webverts
6 weeks ago

  • Keywords has-screenshots added

Replying to jorbin:

For people that are seeing a larger than expected icon, can you please check:

1) When the admin bar is loaded on the front end, ​https://<your-site>/wp-includes/css/admin-bar.min.css?ver=7.1 is also loaded?

Yes Loaded. Only 7.1 is loaded

2) In that file, there is a #wpadminbar #wp-admin-bar-site-name>.ab-item .site-icon rule that includes a width and height instruction?

Yes, 28x28

#wpadminbar #wp-admin-bar-site-name > .ab-item .site-icon {
		position: absolute;
		top: 9px;
		left: 12px;
		width: 28px;
		height: 28px;
		margin: 0;
		border-radius: 4px;
	}

3) If you use the inspector, do you see any rules applying on the img.site-icon file from other sources such as those from a theme or plugin?

The image now loads a 32px and 64px cropped image file

<a class="ab-item" role="menuitem" aria-expanded="false" href="https://domain.com/"><img class="site-icon" src="https://domain.com/wp-content/uploads/cropped-domain-32x32.png" srcset="https://domain.com/wp-content/uploads/cropped-domain-64x64.png 2x" alt="" width="20" height="20" style="
">domain</a>

I tried updating the logo from General Setting. Just selected the icon(512X512), but never saved it in the setting page. Now half of the setting page is now covered with the site logo from the admin bar. Image attached.

<a class="ab-item" role="menuitem" aria-expanded="false" href="https://domain.com/"><img class="site-icon" src="https://domain.com/wp-content/uploads/cropped-domain.png" alt="" width="20" height="20">domain</a>

This ticket was mentioned in ​Slack in #core by adrianduffell. ​View the logs.


6 weeks ago

#22 @adrianduffell
6 weeks ago

  • Owner set to adrianduffell
  • Status new → assigned

#23 @adrianduffell
5 weeks ago

A possible cause could be a plugin/theme having img rules with greater specificity in CSS. A PR is being explored here ​https://github.com/WordPress/wordpress-develop/pull/13243

#24 @dyin
5 weeks ago

@adrianduffell this could be possible and added by a pugin like imagify

This ticket was mentioned in ​PR #13243 on ​WordPress/wordpress-develop by ​@iamchitti.


5 weeks ago
#25

  • Keywords has-patch added

## Ticket

Trac ticket: https://core.trac.wordpress.org/ticket/65912

## 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
https://github.com/user-attachments/assets/af3c30d3-3ac4-4ccd-aea2-0917be916a57 https://github.com/user-attachments/assets/442fdca0-a6cf-47dc-be9d-a73d4706fadd

## Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5
Used for: reproducing the bug locally.

This ticket was mentioned in ​Slack in #core by adamsilverstein. ​View the logs.


5 weeks ago

​@adamsilverstein commented on ​PR #13243:


5 weeks ago
#27

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.

This ticket was mentioned in ​Slack in #core by adrianduffell. ​View the logs.


5 weeks ago

​@joedolson commented on ​PR #13243:


5 weeks ago
#29

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:


5 weeks ago
#30

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-icon already has a high specificity of 2-2-0, and it is scoped to the Site Title link.
    • Increasing the selector specificity also affects anyone overriding properties related to position and border-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:


5 weeks ago
#31

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.

#32 @adamsilverstein
5 weeks ago

  • Milestone 7.1.1 → 7.1.2

7.1.1 RC is in a couple of hours - punting this to 7.1.2 for continued work.

This ticket was mentioned in ​Slack in #core by adrianduffell. ​View the logs.


4 weeks ago

#34 @johnbillion
3 weeks ago

  • Milestone 7.1.2 → 7.1.3

#35 @whyisjake
2 weeks ago

  • Keywords commit added

#36 @whyisjake
2 weeks ago

  • Resolution → fixed
  • Status assigned → closed

In 64034:

Toolbar: Constrain the site icon's size.

The toolbar site icon added in 7.1 is sized only by width and height. A theme or plugin rule such as img { width: auto !important; height: auto !important; } overrides those, and the icon renders at the size of the image file. Add matching max-width, max-height, min-width, and min-height, and qualify the selector with img for added specificity, so the icon stays 20 pixels square, or 28 pixels on small screens.

Follow-up to r62625.

Props donniam, kgagne, khokansardar, jorbin, webverts, adrianduffell, iamchitti, joedolson, sabernhardt, adamsilverstein.
Fixes #65912.

#37 @whyisjake
2 weeks ago

In 64035:

Toolbar: Constrain the site icon's size.

The toolbar site icon added in 7.1 is sized only by width and height. A theme or plugin rule such as img { width: auto !important; height: auto !important; } overrides those, and the icon renders at the size of the image file. Add matching max-width, max-height, min-width, and min-height, and qualify the selector with img for added specificity, so the icon stays 20 pixels square, or 28 pixels on small screens.

Follow-up to r62625.

Reviewed by <second-committer>.
Merges r64034 to the 7.1 branch.

Props donniam, kgagne, khokansardar, jorbin, webverts, adrianduffell, iamchitti, joedolson, sabernhardt, adamsilverstein.
Fixes #65912.

Last edited 2 weeks ago by whyisjake (previous) (diff)

#38 @joedolson
2 weeks ago

@whyisjake Can you add a comment to fill in the missing second committer review?

#39 follow-up: @whyisjake
2 weeks ago

I can't seem to update that comment, so for the record, I was the second reviewer.

#40 in reply to: ↑ 39 @jorbin
13 days ago

Replying to whyisjake:

I can't seem to update that comment, so for the record, I was the second reviewer.

Then who was the first reviewer since you were the committer?

#41 @afercia
13 days ago

Just a note that [64034] introduces a few over-qualified CSS selectors like img.site-icon. Those are ​against the WordPress CSS Coding Standards and will be marked as violations once ​https://github.com/WordPress/wordpress-develop/pull/12934 lands in Core.
Not a problem because that PR will need to be rebased on top of latest trunk before it gets merged and the Stylelint suppressions list will need to be updated (so that it will mark the baseline at that moment).
Just wanted to note that we should avoid introducing new violations.

Note: See TracTickets for help on using tickets.