Ticket #32137: 32137.5.patch
File 32137.5.patch, 1.9 KB (added by , 10 years ago) |
---|
-
media.php
865 865 return $src; 866 866 } 867 867 868 if ( $return === 'id' ) { 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; -
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 // Get the image URL from the image ID, according to image_default_size option. 88 $src_array = wp_get_attachment_image_src( $image_id, get_option('image_default_size') ); 89 $new_src = $src_array[0]; 90 86 91 // Replace the POSTED content <img> with correct uploaded ones. 87 92 // Need to do it in two steps so we don't replace links to the original image if any. 88 93 $new_image = str_replace( $image_src, $new_src, $image ); 89 94 $content = str_replace( $image, $new_image, $content ); 95 96 // Replace the full image size class name with default image size class name, 97 // if specified. 98 if ( ! preg_match( '/(class="[^"]+)"/', $image, $class_matches ) ) { 99 continue; 100 } 101 $class = $class_matches[1]; 102 $new_class = $class; 103 if (get_option('image_default_size') != '' && get_option('image_default_size') != 'full') { 104 $new_class = str_replace( 'size-full', 'size-' . get_option('image_default_size'), $class ); 105 } 106 107 $content = str_replace( $class, $new_class, $content ); 90 108 } 91 109 } 92 110 }