WordPress.org

Make WordPress Core

Ticket #16984: 16984.diff

File 16984.diff, 1.9 KB (added by duck_, 3 years ago)
  • trunk/wordpress-importer.php

     
    822822                $post_id = wp_insert_attachment( $post, $upload['file'] ); 
    823823                wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) ); 
    824824 
    825                 // remap the thumbnail url.  this isn't perfect because we're just guessing the original url. 
    826                 if ( preg_match( '@^image/@', $info['type'] ) && $thumb_url = wp_get_attachment_thumb_url( $post_id ) ) { 
     825                // remap resized image URLs, works by stripping the extension and remapping the URL stub. 
     826                if ( preg_match( '!^image/!', $info['type'] ) ) { 
    827827                        $parts = pathinfo( $url ); 
    828                         $ext = $parts['extension']; 
    829                         $name = basename($parts['basename'], ".{$ext}"); 
    830                         $this->url_remap[$parts['dirname'] . '/' . $name . '.thumbnail.' . $ext] = $thumb_url; 
     828                        $name = basename( $parts['basename'], ".{$parts['extension']}" ); // PATHINFO_FILENAME in PHP 5.2 
     829 
     830                        $parts_new = pathinfo( $upload['url'] ); 
     831                        $name_new = basename( $parts_new['basename'], ".{$parts_new['extension']}" ); 
     832 
     833                        $this->url_remap[$parts['dirname'] . '/' . $name] = $parts_new['dirname'] . '/' . $name_new; 
    831834                } 
    832835 
    833836                return $post_id; 
     
    886889 
    887890                // keep track of the old and new urls so we can substitute them later 
    888891                $this->url_remap[$url] = $upload['url']; 
    889                 $this->url_remap[$post['guid']] = $upload['url']; 
    890                 // if the remote url is redirected somewhere else, keep track of the destination too 
     892                $this->url_remap[$post['guid']] = $upload['url']; // r13735, really needed? 
     893                // keep track of the destination if the remote url is redirected somewhere else 
    891894                if ( isset($headers['x-final-location']) && $headers['x-final-location'] != $url ) 
    892895                        $this->url_remap[$headers['x-final-location']] = $upload['url']; 
    893896