public function make_content_images_responsive( $content ) {
		// Select images in content
		if ( ! preg_match_all( '/<img [^>]+>/', $content, $matches ) ) {
			return $content;
		}

		$selected_images = array();
		$attachment_ids  = array();

		/**
		 * Loop through possible images and get attachment ids.
		 *
		 * Ignore images that already contain a srcset.
		 */
		foreach ( $matches[0] as $image ) {
			if ( false === strpos( $image, ' srcset=' )
				&& preg_match( '/wp-image-([0-9]+)/i', $image, $class_id )
				&& ( $attachment_id = absint( $class_id[1] ) )
			) {
				/**
				 * If exactly the same image tag is used more than once, overwrite it.
				 * All identical tags will be replaced later with str_replace().
				 */
				$selected_images[ $image ] = $attachment_id;

				// Overwrite the ID when the same image is included more than once.
				$attachment_ids[ $attachment_id ] = true;
			}
		}

		/**
		 * Warm object cache for use with 'get_post_meta()'.
		 *
		 * To avoid making a database call for each image, a single query warms the object cache
		 * with the meta information for all images.
		 */
		if ( count( $attachment_ids ) > 1 ) {
			update_meta_cache( 'post', array_keys( $attachment_ids ) );
		}

		// Loop through images and apply responsive markup
		foreach ( $selected_images as $image => $attachment_id ) {
			$image_updated = $this->generate_srcset_and_sizes( $image, $attachment_id );
			$content       = str_replace( $image, $image_updated, $content );
		}

		return $content;
	}
public function make_content_images_responsive( $content ) {
		// Select images in content
		if ( ! preg_match_all( '/<img [^>]+>/', $content, $matches ) ) {
			return $content;
		}

		$selected_images = array();
		$attachment_ids  = array();

		/**
		 * Loop through possible images and get attachment ids.
		 *
		 * Ignore images that already contain a srcset.
		 */
		foreach ( $matches[0] as $image ) {
			if ( false === strpos( $image, ' srcset=' )
				&& preg_match( '/wp-image-([0-9]+)/i', $image, $class_id )
				&& ( $attachment_id = absint( $class_id[1] ) )
			) {
				/**
				 * If exactly the same image tag is used more than once, overwrite it.
				 * All identical tags will be replaced later with str_replace().
				 */
				$selected_images[ $image ] = $attachment_id;

				// Overwrite the ID when the same image is included more than once.
				$attachment_ids[ $attachment_id ] = true;
			}
		}

		/**
		 * Warm object cache for use with 'get_post_meta()'.
		 *
		 * To avoid making a database call for each image, a single query warms the object cache
		 * with the meta information for all images.
		 */
		if ( count( $attachment_ids ) > 1 ) {
			update_meta_cache( 'post', array_keys( $attachment_ids ) );
		}

		// Loop through images and apply responsive markup
		foreach ( $selected_images as $image => $attachment_id ) {
			$image_updated = $this->generate_srcset_and_sizes( $image, $attachment_id );
			$content       = str_replace( $image, $image_updated, $content );
		}

		return $content;
	}
public function make_content_images_responsive ( $ content ) { // Select images in content if ( ! preg_match_all ( '/<img [^>]+>/' , $ content , $ matches ) ) { return $ content ; } $ selected_images = array ( ) ; $ attachment_ids = array ( ) ; /**
		 * Loop through possible images and get attachment ids.
		 *
		 * Ignore images that already contain a srcset.
		 */ foreach ( $ matches [ 0 ] as $ image ) { if ( false === strpos ( $ image , ' srcset=' ) && preg_match ( '/wp-image-([0-9]+)/i' , $ image , $ class_id ) && ( $ attachment_id = absint ( $ class_id [ 1 ] ) ) ) { /**
				 * If exactly the same image tag is used more than once, overwrite it.
				 * All identical tags will be replaced later with str_replace().
				 */ $ selected_images [ $ image ] = $ attachment_id ; // Overwrite the ID when the same image is included more than once. $ attachment_ids [ $ attachment_id ] = true ; } } /**
		 * Warm object cache for use with 'get_post_meta()'.
		 *
		 * To avoid making a database call for each image, a single query warms the object cache
		 * with the meta information for all images.
		 */ if ( count ( $ attachment_ids ) > 1 ) { update_meta_cache ( 'post' , array_keys ( $ attachment_ids ) ) ; } // Loop through images and apply responsive markup foreach ( $ selected_images as $ image => $ attachment_id ) { $ image_updated = $ this -> generate_srcset_and_sizes ( $ image , $ attachment_id ) ; $ content = str_replace ( $ image , $ image_updated , $ content ) ; } return $ content ; }
Filter content and apply responsive image markup to images.

@see wp_make_content_images_responsive()

@param string $content Post content.

@return string Filtered content
Filter content and apply responsive image markup to images .