0

Is there an extension, or a technique, during Wordpress import to pull in an attachment URL that doesn't have a file extension?

I'm trying to import a Square Space blog into Wordpress. Most of the posts and URLs come over, but there's a small number (eight), where the images can't be imported. The importer fails with a message like

Failed to import Media “attachment-50b1b915e4b01c11f0ef7db4”: Invalid file type

If I lookup the attachment-50b1b915e4b01c11f0ef7db4 attachment in the XML import file, I find the following item node set

<item>
  <wp:attachment_url>http://static.squarespace.com/static/50a97ccee4b040d1420f6022/50a97ccee4b040d1420f6032/50b1b915e4b01c11f0ef7db4/1353824560608/file</wp:attachment_url>
  <link>http://static.squarespace.com/static/50a97ccee4b040d1420f6022/50a97ccee4b040d1420f6032/50b1b915e4b01c11f0ef7db4/1353824560608/file</link>
  <title>attachment-50b1b915e4b01c11f0ef7db4</title>
  <wp:post_name>file</wp:post_name>
  <wp:post_type>attachment</wp:post_type>
  <wp:post_id>91</wp:post_id>
  <wp:post_parent>90</wp:post_parent>
  <wp:status>inherit</wp:status>
  <content:encoded><![CDATA[img-50b1b915e4b01c11f0ef7db4]]></content:encoded>
  <excerpt:encoded><![CDATA[exc-50b1b915e4b01c11f0ef7db4]]></excerpt:encoded>
  <pubDate>Sun, 25 Nov 2012 06:22:13 +0000</pubDate>
  <wp:post_date>2012-11-25 06:22:13</wp:post_date>
  <wp:post_date_gmt>2012-11-25 06:22:13</wp:post_date_gmt>
  <dc:creator>astorm@example.com</dc:creator>
</item>

Zooming in on the attachment URL, that's

http://static.squarespace.com/static/50a97ccee4b040d1420f6022/50a97ccee4b040d1420f6032/50b1b915e4b01c11f0ef7db4/1353824560608/file

There's no file extension on this URL. It appears that the wordpress-importer plugin checks the file types of the URL by extension, using the wp_get_mime_types function.

Is there a way to work around this by mapping via the Content/Type header, or manually mapping specific URLs to specific file types during import?

0

With no native solution popping up here, I ended up writing a script that

  • Parsed my the XML import file I had and identified problem attachments
  • Manually download those attachments with a file extension
  • Upload those images to a new web server
  • Alter the appropriate link and wp:attachment_url nodes to point to the new URLs
  • Re-save the XML

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.