Ticket #44427: 44427.2.diff
File 44427.2.diff, 3.2 KB (added by , 19 months ago) |
---|
-
src/wp-includes/default-filters.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
176 176 add_filter( 'the_content', 'shortcode_unautop' ); 177 177 add_filter( 'the_content', 'prepend_attachment' ); 178 178 add_filter( 'the_content', 'wp_make_content_images_responsive' ); 179 add_filter( 'the_content', 'wp_make_content_images_lazy' ); 179 180 180 181 add_filter( 'the_excerpt', 'wptexturize' ); 181 182 add_filter( 'the_excerpt', 'convert_smilies' ); -
src/wp-includes/media.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
966 966 'class' => "attachment-$size_class size-$size_class", 967 967 'alt' => trim( strip_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) ), 968 968 ); 969 969 if ( current_theme_supports( 'lazy-loading-images' ) ) { 970 $default_attr['loading'] = 'lazy'; 971 } 970 972 $attr = wp_parse_args( $attr, $default_attr ); 971 973 972 974 // Generate 'srcset' and 'sizes' if not already present. … … 1528 1530 return $image; 1529 1531 } 1530 1532 1533 /** 1534 * Filters 'img' elements in post content to add 'loading' attributes. 1535 * 1536 * @param string $content The raw post content to be filtered. 1537 * 1538 * @since 5.x.x 1539 * 1540 * @return string Converted content with 'loading' attributes added to images. 1541 * @see wp_tag_add_lazy_load() 1542 * 1543 */ 1544 function wp_make_content_images_lazy( $content ) { 1545 if ( current_theme_supports( 'lazy-loading-images' ) ) { 1546 $content = wp_tag_add_lazy_load( $content, 'img' ); 1547 } 1548 1549 return $content; 1550 } 1551 1552 1553 /** 1554 * Filters html tag elements in post content to add 'loading' attributes. 1555 * 1556 * @param string $content The raw post content to be filtered. 1557 * @param string $tag The html tag to scan and replace with loading attribute. Default: img 1558 * 1559 * @since 5.x.x 1560 * 1561 * @return string Converted content with 'loading' attributes added to images. 1562 */ 1563 function wp_tag_add_lazy_load( $content, $tag = 'img' ) { 1564 if ( ! preg_match_all( '/<' . $tag . ' [^>]+>/', $content, $matches ) ) { 1565 return $content; 1566 } 1567 1568 $images = array_shift( $matches ); 1569 1570 foreach ( $images as $image ) { 1571 if ( false === strpos( $image, ' loading=' ) ) { 1572 $lazy_image = str_replace( '<' . $tag . ' ', '<' . $tag . ' loading="lazy" ', $image ); 1573 $content = str_replace( $image, $lazy_image, $content ); 1574 } 1575 } 1576 1577 return $content; 1578 } 1579 1531 1580 /** 1532 1581 * Adds a 'wp-post-image' class to post thumbnails. Internal use only. 1533 1582 * -
src/wp-includes/pluggable.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
2561 2561 'extra_attr' => '', 2562 2562 ); 2563 2563 2564 if ( current_theme_supports( 'lazy-loading-images' ) ) { 2565 $defaults['loading'] = 'lazy'; 2566 } 2567 2564 2568 if ( empty( $args ) ) { 2565 2569 $args = array(); 2566 2570 }