Make WordPress Core

Ticket #32137: 32137.2.patch

File 32137.2.patch, 1.5 KB (added by topdownjimmy, 10 years ago)

Different method, interferes less with media_sideload_image()

  • media.php

     
    865865                        return $src;
    866866                }
    867867
     868                if ( $return === 'id' ) {
     869                        return $id;
     870                }
     871
    868872                $alt = isset( $desc ) ? esc_attr( $desc ) : '';
    869873                $html = "<img src='$src' alt='$alt' />";
    870874                return $html;
  • class-wp-press-this.php

     
    8080                                }
    8181
    8282                                // Sideload image, which gives us a new image src.
    83                                 $new_src = media_sideload_image( $image_src, $post_id, null, 'src' );
     83                                $image_id = media_sideload_image( $image_src, $post_id, null, 'id' );
     84                                $src_array = wp_get_attachment_image_src( $image_id, get_option('image_default_size') );
     85                                $new_src = $src_array[0];
    8486
    8587                                if ( ! is_wp_error( $new_src ) ) {
    8688                                        // Replace the POSTED content <img> with correct uploaded ones.
    8789                                        // Need to do it in two steps so we don't replace links to the original image if any.
    8890                                        $new_image = str_replace( $image_src, $new_src, $image );
     91                                        // Replace the full image size class name with default image size class name,
     92                                        // if specified.
     93                                        if (get_option('image_default_size') != '' && get_option('image_default_size') !== 'full') {
     94                                                $new_image = str_replace( 'size-full', 'size-' . get_option('image_default_size'), $new_image );
     95                                        }
    8996                                        $content = str_replace( $image, $new_image, $content );
    9097                                }
    9198                        }