You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How do plugins change the block editor icon? #38555
I want to bundle an image in my (private) plugin, and use it as the icon that shows in the top-left corner of the block editor screen.
There is an official filter for changing the site icon, but it is not used when resolving the block editor icon. Apparently, the only way to change the default icon is through an attachment post ID, which seems unnecessarily stringent.
Either the existing filter should be used here, or there should be a second filter specifically for the block editor icon.
I would appreciate this to be considered a high priority and considered a bug, not an enhancement. It should always be easy for plugins to disable the default branding.
Step-by-step reproduction instructions
Install a hypothetical plugin that re-brands the admin without inserting new attachment posts
Continue to see the default icon in the block editor
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Although I didn't want to do this by setting a site icon through the customiser, I tried it anyway for the time being, and I am finding that I can't even change the block editor icon this way. Nothing I try will change the default icon.
Using core version 5.9 with all plugins deactivated.
Thanks for the code, it solves what I want to do. I did come across that hook in my research but couldn't spot how to use it. Still not sure why the customiser didn't work?
Although I didn't want to do this by setting a site icon through the customiser, I tried it anyway for the time being, and I am finding that I can't even change the block editor icon this way. Nothing I try will change the default icon.
Using core version 5.9 with all plugins deactivated.
Confirmed to work with the gutenberg plugin active, but not when inactive.
I notice that some code handling the site icon that passes through this filter was only added in core version 5.9, which suggests that the regression might have happened in that version. On the other hand, I can't find anything in version 5.8.3 to handle the site icon.
Does anyone know whether the icon replacement was ever possible in core, or only with the plugin active?
Activity
carlomanf commentedon Feb 7, 2022
Although I didn't want to do this by setting a site icon through the customiser, I tried it anyway for the time being, and I am finding that I can't even change the block editor icon this way. Nothing I try will change the default icon.
Using core version 5.9 with all plugins deactivated.
t-hamano commentedon Feb 7, 2022
How about using the rest_index hook?
Like this:
carlomanf commentedon Feb 7, 2022
Thanks for the code, it solves what I want to do. I did come across that hook in my research but couldn't spot how to use it. Still not sure why the customiser didn't work?
t-hamano commentedon Feb 7, 2022
I haven't analyzed it in depth, so I don't know if the lack of functioning of the customizer is a specification or a bug.
I will look into it again if I have time.
carlomanf commentedon Feb 8, 2022
Confirmed to work with the gutenberg plugin active, but not when inactive.
carlomanf commentedon Feb 21, 2022
I notice that some code handling the site icon that passes through this filter was only added in core version 5.9, which suggests that the regression might have happened in that version. On the other hand, I can't find anything in version 5.8.3 to handle the site icon.
Does anyone know whether the icon replacement was ever possible in core, or only with the plugin active?
carlomanf commentedon Sep 6, 2022
It looks like this was fixed by WordPress/wordpress-develop#3157