Ticket #8340: 8340.03.patch
File 8340.03.patch, 5.3 KB (added by , 4 years ago) |
---|
-
src/bp-activity/bp-activity-embeds.php
267 267 $float_width = 350; 268 268 269 269 // Set up thumb. 270 $content = sprintf( '<div class="thumb" style="max-width:%1$spx">%2$s<a href="%3$s" rel="nofollow" onclick="top.location.href=\'%3$s\'"><img src="%4$s" alt="" /></a></div>', $thumb_width, $play_icon, esc_url( $url ), esc_url( $thumbnail ) );270 $content = sprintf( '<div class="thumb" style="max-width:%1$spx">%2$s<a href="%3$s" rel="nofollow" onclick="top.location.href=\'%3$s\'"><img loading="lazy" src="%4$s" alt="" /></a></div>', $thumb_width, $play_icon, esc_url( $url ), esc_url( $thumbnail ) ); 271 271 272 272 // Show title. 273 273 if ( isset( $oembed->title ) ) { -
src/bp-activity/bp-activity-filters.php
93 93 add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_make_nofollow_filter' ); 94 94 add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_make_nofollow_filter' ); 95 95 96 add_filter( 'bp_get_activity_content_body', 'bp_core_add_loading_lazy_attribute' ); 97 add_filter( 'bp_activity_comment_content', 'bp_core_add_loading_lazy_attribute' ); 98 96 99 add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' ); 97 100 add_filter( 'the_content', 'bp_activity_at_name_filter' ); 98 101 add_filter( 'bp_activity_get_embed_excerpt', 'bp_activity_at_name_filter' ); -
src/bp-core/bp-core-filters.php
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 * … … 899 902 return $edit_link; 900 903 } 901 904 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 902 930 /** 903 931 * Should BuddyPress load the mentions scripts and related assets, including results to prime the 904 932 * mentions suggestions? -
src/bp-groups/bp-groups-blocks.php
110 110 $avatar_container = sprintf( 111 111 '<div class="item-header-avatar"> 112 112 <a href="%1$s"> 113 <img src="%2$s" alt="%3$s" class="avatar">113 <img loading="lazy" src="%2$s" alt="%3$s" class="avatar"> 114 114 </a> 115 115 </div>', 116 116 esc_url( $group_link ), -
src/bp-groups/classes/class-bp-groups-component.php
892 892 ) ); 893 893 894 894 if ( empty( $bp->bp_options_avatar ) ) { 895 $bp->bp_options_avatar = '<img src="' . esc_url( bp_core_avatar_default_thumb() ) . '" alt="' . esc_attr__( 'No Group Profile Photo', 'buddypress' ) . '" class="avatar" />';895 $bp->bp_options_avatar = '<img loading="lazy" src="' . esc_url( bp_core_avatar_default_thumb() ) . '" alt="' . esc_attr__( 'No Group Profile Photo', 'buddypress' ) . '" class="avatar" />'; 896 896 } 897 897 } 898 898 } -
src/bp-members/bp-members-blocks.php
106 106 $avatar_container = sprintf( 107 107 '<div class="item-header-avatar"> 108 108 <a href="%1$s"> 109 <img src="%2$s" alt="%3$s" class="avatar">109 <img loading="lazy" src="%2$s" alt="%3$s" class="avatar"> 110 110 </a> 111 111 </div>', 112 112 esc_url( $member_link ), -
src/bp-messages/bp-messages-filters.php
79 79 add_filter( 'bp_get_the_thread_subject', 'stripslashes_deep' ); 80 80 add_filter( 'bp_get_message_thread_content', 'stripslashes_deep', 1 ); 81 81 82 add_filter( 'bp_get_the_thread_message_content', 'bp_core_add_loading_lazy_attribute' ); 83 82 84 // Personal data export. 83 85 add_filter( 'wp_privacy_personal_data_exporters', 'bp_messages_register_personal_data_exporter' ); 84 86