Ticket #32137: 32137.7.patch
| File 32137.7.patch, 2.3 KB (added by , 11 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 92 if ( !empty($src_array) ) { 93 continue; 94 } 95 $new_src = $src_array[0]; 96 86 97 // Replace the POSTED content <img> with correct uploaded ones. 87 98 // Need to do it in two steps so we don't replace links to the original image if any. 88 99 $new_image = str_replace( $image_src, $new_src, $image ); 89 100 $content = str_replace( $image, $new_image, $content ); 101 102 // Replace the full image size class name with default image size class name, 103 // if specified. 104 if ( ! preg_match( '/(class=["\'][^"^\']+)["\']/', $image, $class_matches ) ) { 105 continue; 106 } 107 $class = $class_matches[1]; 108 $new_class = $class; 109 if ( '' !== $image_default_size && 'full' !== $image_default_size ) { 110 $new_class = str_replace( 'size-full', 'size-' . $image_default_size, $class ); 111 } 112 $content = str_replace( $class, $new_class, $content ); 90 113 } 91 114 } 92 115 }