@@ -19,12 +19,19 @@ public static function instance() {
1919 * Registers actions
2020 */
2121 private function __construct () {
22+ if ( is_admin () ) {
23+ return ;
24+ }
25+
2226 // modify content
2327 add_action ( 'wp_head ' , array ( $ this , 'setup_filters ' ), 9999 ); // we don't really want to modify anything in <head> since it's mostly all metadata
2428
2529 // js to do lazy loading
2630 add_action ( 'init ' , array ( $ this , 'register_assets ' ) );
2731 add_action ( 'wp_enqueue_scripts ' , array ( $ this , 'enqueue_assets ' ) );
32+
33+ // Do not lazy load avatar in admin bar
34+ add_action ( 'admin_bar_menu ' , array ( $ this , 'remove_filters ' ), 0 );
2835 }
2936
3037 public function setup_filters () {
@@ -33,6 +40,12 @@ public function setup_filters() {
3340 add_filter ( 'get_avatar ' , array ( $ this , 'add_image_placeholders ' ), 11 );
3441 }
3542
43+ public function remove_filters () {
44+ remove_filter ( 'the_content ' , array ( $ this , 'add_image_placeholders ' ), 99 );
45+ remove_filter ( 'post_thumbnail_html ' , array ( $ this , 'add_image_placeholders ' ), 11 );
46+ remove_filter ( 'get_avatar ' , array ( $ this , 'add_image_placeholders ' ), 11 );
47+ }
48+
3649 public function add_image_placeholders ( $ content ) {
3750 // Don't lazyload for feeds, previews
3851 if ( is_feed () || is_preview () ) {
0 commit comments