diff --git src/bp-core/bp-core-filters.php src/bp-core/bp-core-filters.php
index ec84a6990..789145f95 100644
|
|
|
add_filter( 'bp_email_set_content_html', 'stripslashes', 8 );
|
| 59 | 59 | add_filter( 'bp_email_set_content_plaintext', 'wp_strip_all_tags', 6 ); |
| 60 | 60 | add_filter( 'bp_email_set_subject', 'sanitize_text_field', 6 ); |
| 61 | 61 | |
| | 62 | // Avatars. |
| | 63 | add_filter( 'bp_core_fetch_avatar', 'bp_core_add_loading_lazy_attribute' ); |
| | 64 | |
| 62 | 65 | /** |
| 63 | 66 | * Template Compatibility. |
| 64 | 67 | * |
| … |
… |
function bp_core_filter_edit_post_link( $edit_link = '', $post_id = 0 ) {
|
| 899 | 902 | return $edit_link; |
| 900 | 903 | } |
| 901 | 904 | |
| | 905 | /** |
| | 906 | * Add 'loading="lazy"' attribute into images. |
| | 907 | * |
| | 908 | * @since 7.0.0 |
| | 909 | * |
| | 910 | * @string $content Content to inject attribute into. |
| | 911 | * @return string |
| | 912 | */ |
| | 913 | function bp_core_add_loading_lazy_attribute( $content = '' ) { |
| | 914 | if ( false === strpos( $content, '<img ' ) ) { |
| | 915 | return $content; |
| | 916 | } |
| | 917 | |
| | 918 | $content = str_replace( '<img ', '<img loading="lazy" ', $content ); |
| | 919 | return $content; |
| | 920 | } |
| | 921 | |
| 902 | 922 | /** |
| 903 | 923 | * Should BuddyPress load the mentions scripts and related assets, including results to prime the |
| 904 | 924 | * mentions suggestions? |
diff --git tests/phpunit/testcases/core/avatars.php tests/phpunit/testcases/core/avatars.php
index b56bf73b6..10ce03d6b 100644
|
|
|
class BP_Tests_Avatars extends BP_UnitTestCase {
|
| 166 | 166 | |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | | $expected_html = '<img src="' . $avatar_url . '" id="' . $this->params['css_id'] . '" class="' . $this->params['class'] . ' ' . $this->params['object'] . '-' . $this->params['item_id'] . '-avatar avatar-' . $this->params['width'] . ' photo" width="' . $this->params['width'] . '" height="' . $this->params['height'] . '" alt="' . $this->params['alt'] . '" title="' . $this->params['title'] . '" ' . $this->params['extra_attr'] . ' />'; |
| | 169 | $expected_html = '<img loading="lazy" src="' . $avatar_url . '" id="' . $this->params['css_id'] . '" class="' . $this->params['class'] . ' ' . $this->params['object'] . '-' . $this->params['item_id'] . '-avatar avatar-' . $this->params['width'] . ' photo" width="' . $this->params['width'] . '" height="' . $this->params['height'] . '" alt="' . $this->params['alt'] . '" title="' . $this->params['title'] . '" ' . $this->params['extra_attr'] . ' />'; |
| 170 | 170 | |
| 171 | 171 | $this->assertEquals( $html, $expected_html ); |
| 172 | 172 | } |