Make WordPress Core

Ticket #34807: 34807.patch

File 34807.patch, 814 bytes (added by azaozz, 9 years ago)
  • src/wp-includes/media.php

     
    12061206 * @return string Converted content with 'srcset' and 'sizes' attributes added to images.
    12071207 */
    12081208function wp_make_content_images_responsive( $content ) {
    1209         $images = get_media_embedded_in_content( $content, 'img' );
     1209        if ( ! preg_match_all( '/<img [^>]+>/', $content, $matches ) ) {
     1210                return $content;
     1211        }
    12101212
    12111213        $selected_images = $attachment_ids = array();
    12121214
    1213         foreach( $images as $image ) {
     1215        foreach( $matches[0] as $image ) {
    12141216                if ( false === strpos( $image, ' srcset=' ) && preg_match( '/wp-image-([0-9]+)/i', $image, $class_id ) &&
    12151217                        ( $attachment_id = absint( $class_id[1] ) ) ) {
    12161218