Make WordPress Core

Changeset 53100

Timestamp:
04/07/2022 10:12:34 PM (2 years ago)
Author:
audrasjb
Message:

Toolbar: Add a filter to help remove site icons from toolbar for large multisite, and lazy load them by default.

This changeset introduces the wp_admin_bar_show_site_icons filter to help developers to hide site icons from the toolbar, as it may have negative performance impact on large multisites. It also adds a default lazy load behavior for these icons.

Props wslyhbb, sabernhardt, lkraav, kebbet, peterwilsoncc.
Fixes #54447

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/admin-bar.php

    r53060 r53100  
    612612    );
    613613
     614
     615
     616
     617
     618
     619
     620
     621
     622
     623
     624
     625
    614626    foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
    615627        switch_to_blog( $blog->userblog_id );
    616628
    617         if ( has_site_icon() ) {
     629        if ( has_site_icon() ) {
    618630            $blavatar = sprintf(
    619                 '<img class="blavatar" src="%s" srcset="%s 2x" alt="" width="16" height="16" />',
     631                '<img class="blavatar" src="%s" srcset="%s 2x" alt="" width="16" height="16" />',
    620632                esc_url( get_site_icon_url( 16 ) ),
    621                 esc_url( get_site_icon_url( 32 ) )
     633                esc_url( get_site_icon_url( 32 ) ),
     634                ( wp_lazy_loading_enabled( 'img', 'site_icon_in_toolbar' ) ? ' loading="lazy"' : '' )
    622635            );
    623636        } else {
Note: See TracChangeset for help on using the changeset viewer.