• Bri

    (@tinnyfusion)


    Hi all, as per the title of this post. I want to have a site logo (Appearance > Customise > Site Identity > Site Icon) but at the same time do not want the logo to change when editing a page/post within the Block Editor. I would much prefer to either keep the original WordPress logo, or ideally, add my own logo separate from the Site Icon.

    Could the following be changed to either prevent the chance when a Site Icon is set or specify another separate custom image to use?

     /** 
      * Overrides the custom logo with a site logo, if the option is set. 
      * 
      * @param string $custom_logo The custom logo set by a theme. 
      * 
      * @return string The site logo if set. 
      */ 
     function override_custom_logo_theme_mod( $custom_logo ) { 
     	$sitelogo = get_option( 'sitelogo' ); 
     	return false === $sitelogo ? $custom_logo : $sitelogo; 
     } 

    Hopefully this can be done.

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    There might be a better way, but you could add custom admin JavaScript that finds the img element in the DOM and changes its src attribute to a logo of your liking. Users may briefly see your site logo when the page loads, but it’ll quickly change to the preferred image.

    You can have external .js files referenced on the editor page by using wp_enqueue_script() called from the “admin_enqueue_scripts” action hook. Your script must ensure the DOM has fully loaded before attempting to modify the src attribute.

    Thread Starter Bri

    (@tinnyfusion)

    Hi @bcworkz, Thank you for your reply. I understand what you are suggesting but given my JavaScript skills are rubbish and I don’t want to be having to set this up for every site I create moving forwards. Could you either provide an example of said script or offer an alternative remedy?

    Personally I’d love to see an option when setting a site logo to enable/disable the change to the editor.

    For what it’s worth I don’t think it makes any sense to select an option to add a site icon but then this also changes the GUI too.

    If I took my car to the garage for new tyres but it came back a whole different colour I’d look at the mechanic gone out.

    stupid analogy but you see my point.

    Cheers,

    Bri

    Moderator bcworkz

    (@bcworkz)

    I see what you’re saying, but others would rather their site logo appear in the editor as it does. Providing a separate option for this was probably seen as needlessly trivial.

    If you don’t like seeing your site logo in the editor, don’t use fullscreen mode ?? I say this in jest, but in fact it is an option you could use. With all the drawbacks associated with non-fullscreen of course.

    I’m not so good with JavaScript either, but I think it’s basically:
    document.getElementsByClassName("edit-post-fullscreen-mode-close_site-icon")[0].src = "https://example.com/wp-content/uploads/icon.png";

    Totally untested and missing the customary code to execute when the document is fully loaded and what not.

    Thread Starter Bri

    (@tinnyfusion)

    Thank you but I’m still at a loss of how to implement this. Maybe a future feature to add to core whereby users are given an option to enable/disable this. Or maybe document how to hook into this to add our own logo. Would be great for easily adding a touch of branding for client sites.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to keep original block editor Icon when setting site Icon?’ is closed to new replies.