Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#5466 closed enhancement (fixed)

Import file attachments

Reported by: tellyworth's profile tellyworth Owned by:
Milestone: 2.5 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: Cc:


The enclosed patch supports file attachment importing with wxr files.

If the 'Import attachments' box is checked on step 2 of the import (the Assign Authors page), the importer will attempt to download attachments from their original URLs to the uploads dir of the local server. I've used the existing upload handling functions as much as possible, with a few tweaks here and there, so correct error handling and capability checks should be enforced.

HTTP fetching is with an expanded version of the wp_get_http_headers() function. I also took the opportunity to remove some duplicate code in wp-admin/includes/file.php.

For now the new import code is in WP_Import, but my plan is to eventually move much of it into a base class so it can be reused by the other importers.

Unit tests are in - see test_import_wp.php, test_includes_file.php and test_includes_functions.php.

Attachments (1)

import_file_attachments-r6377.patch (12.9 KB) - added by tellyworth 16 years ago.

Download all attachments as: .zip

Change History (4)

#1 @tellyworth
16 years ago

  • Keywords has-patch added

Forgot to add: the importer will automatically adjust URLs in post_content to point to attachments at their new locations. It doesn't work with attachment page URLs, just the direct file URLs. Thumbnails aren't handled at all.

Here's an export file for testing:

#2 @lloydbudd
16 years ago

  • Milestone changed from 2.5 to 2.4

#3 @ryan
16 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [6390]) Import file attachments. Props tellyworth. fixes #5466

Note: See TracTickets for help on using tickets.