Changeset 12757 for trunk/src/bp-core/bp-core-filters.php
- Timestamp:
- 10/16/2020 06:02:01 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-filters.php
r12678 r12757 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 62 // Avatars. 63 add_filter( 'bp_core_fetch_avatar', 'bp_core_add_loading_lazy_attribute' ); 61 64 62 65 /** … … 901 904 902 905 /** 906 * Add 'loading="lazy"' attribute into images and iframes. 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 ' ) && false === strpos( $content, '<iframe ' ) ) { 915 return $content; 916 } 917 918 $content = str_replace( '<img ', '<img loading="lazy" ', $content ); 919 $content = str_replace( '<iframe ', '<iframe loading="lazy" ', $content ); 920 921 // WordPress posts need their position absolute removed for lazyloading. 922 $find_pos_absolute = ' style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" '; 923 if ( false !== strpos( $content, 'data-secret=' ) && false !== strpos( $content, $find_pos_absolute ) ) { 924 $content = str_replace( $find_pos_absolute, '', $content ); 925 } 926 927 return $content; 928 } 929 930 /** 903 931 * Should BuddyPress load the mentions scripts and related assets, including results to prime the 904 932 * mentions suggestions?
Note: See TracChangeset
for help on using the changeset viewer.