Making WordPress.org

Changeset 9603


Ignore:
Timestamp:
03/18/2020 11:30:59 PM (5 years ago)
Author:
coffee2code
Message:

Support Forums: Lazy-load avatars.

Props jonoaldersonwp, coffee2code.
Fixes #5071.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

    r9489 r9603  
    3838        add_filter( 'bbp_after_get_reply_author_link_parse_args', array( $this, 'get_author_link' ) );
    3939        add_filter( 'bbp_after_get_author_link_parse_args',       array( $this, 'get_author_link' ) );
     40
     41        // Mark avatar images as being lazy-loadable.
     42        add_filter( 'get_avatar', array( $this, 'avatar_lazy_load' ) );
    4043
    4144        // remove nofollow filter from topic and reply author links, since those are wordpress.org profile urls, not user inputs
     
    574577
    575578    /**
     579     * Change avatar `img` markup to indicate lazy loading of image.
     580     */
     581    public function avatar_lazy_load( $markup ) {
     582        return str_replace( '<img ', '<img loading="lazy" ', $markup );
     583    }
     584
     585    /**
    576586     * Removes oEmbed discovery links for bbPress' post types.
    577587     *
Note: See TracChangeset for help on using the changeset viewer.