Ticket #32137: 32137.6.patch
File 32137.6.patch, 2.4 KB (added by , 10 years ago) |
---|
-
wp-admin/includes/media.php
861 861 862 862 // Finally check to make sure the file has been saved, then return the HTML. 863 863 if ( ! empty( $src ) ) { 864 if ( $return === 'src') {864 if ( 'src' === $return ) { 865 865 return $src; 866 866 } 867 867 868 if ( 'id' === $return ) { 869 return $id; 870 } 871 868 872 $alt = isset( $desc ) ? esc_attr( $desc ) : ''; 869 873 $html = "<img src='$src' alt='$alt' />"; 870 874 return $html; -
wp-admin/includes/class-wp-press-this.php
79 79 continue; 80 80 } 81 81 82 // Sideload image, which gives us a new image src.83 $ new_src = media_sideload_image( $image_src, $post_id, null, 'src' );82 // Sideload image, which gives us a new image ID. 83 $image_id = media_sideload_image( $image_src, $post_id, null, 'id' ); 84 84 85 if ( ! is_wp_error( $new_src ) ) { 85 if ( ! is_wp_error( $image_id ) ) { 86 87 $image_default_size = get_option('image_default_size'); 88 89 // Get the image URI from the image ID, according to image_default_size option. 90 $src_array = wp_get_attachment_image_src( $image_id, $image_default_size ); 91 $new_src = $src_array[0]; 92 93 // Make sure we got an image URI 94 if ( ! preg_match( '/[^\?]+\.(?:jpe?g|jpe|gif|png)(?:\?|$)/i', $new_src ) ) { 95 continue; 96 } 97 86 98 // Replace the POSTED content <img> with correct uploaded ones. 87 99 // Need to do it in two steps so we don't replace links to the original image if any. 88 100 $new_image = str_replace( $image_src, $new_src, $image ); 89 101 $content = str_replace( $image, $new_image, $content ); 102 103 // Replace the full image size class name with default image size class name, 104 // if specified. 105 if ( ! preg_match( '/(class=["\'][^"^\']+)["\']/', $image, $class_matches ) ) { 106 continue; 107 } 108 $class = $class_matches[1]; 109 $new_class = $class; 110 if ( '' !== $image_default_size && 'full' !== $image_default_size ) { 111 $new_class = str_replace( 'size-full', 'size-' . $image_default_size, $class ); 112 } 113 $content = str_replace( $class, $new_class, $content ); 90 114 } 91 115 } 92 116 }