WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can You Modify "Import File Attachments" to Import Files with No Extension? (5 posts)

  1. rossruns
    Member
    Posted 4 years ago #

    I've written a tool to convert a Vox.com blog into a WXR-compatible format for importing into a WordPress blog. I would like to be able to also create all the blog-hosted images as attachments in the WXR file so you can check the "Download and import file attachments" box during the import process and have them auto-port the images into the new blog as well.

    Unfortunately, Vox.com hosts their images in a URL without any file extension (e.g. http://a5.vox.com/6a00d4142121106a47011016caba2d860d-pi ) and relies on the browser to display the image properly. [Not the best approach in my book, but that's something I can't change so that's beside the point.]

    When I try to import an attachment I've created in the WXR file pointing to this, I get the "Remote file error: Invalid file type" error, presumably because this isn't one of the valid MIME types verified when the import calls the wp_check_filetype() function.

    Is there a way to allow WordPress to import attachments with no file extension? I see there is a plugin called pjw-mime-config that allows you to add new whitelisted MIME types based on file extension, but trying to add one with no file extension didn't help as I still received the above error when I tried to do an import on the WXR file that had that attachment.

    I have successfully imported an attachment that has a .gif file extension on the image, so I know for a fact my attachment code works and it's just the extension-less images that are causing the problem.

    Any help would be greatly appreciated. My export tool works fine for exporting text posts, but I'd love to be able to allow users to also easily export/import their images from a Vox blog to their new WordPress blog.

  2. rossruns
    Member
    Posted 4 years ago #

    Nothing?

  3. James Revillini
    Member
    Posted 4 years ago #

    This isn't an answer to your question, but my guess is that the changes to the core required to make this work would be so pervasive that no one wants to tackle it. I base this on the fact that we have to specify the allowed file extensions and not the allowed mime types. The server you're importing from probably sends the gif/x-image (or whatever) mime type, but WordPress is agnostic of import mime type.

    I wonder if files from mac computers with no file extension can be uploaded.

  4. s_ha_dum
    Member
    Posted 4 years ago #

    Why not have your script scan the image files for a file type and add the extension as you do the conversion? Maybe something like this? This is assuming, though, that you are uploading the images to WP's server and not trying to link directly to the Vox images.

  5. rossruns
    Member
    Posted 4 years ago #

    Yeah apljdi, that's the problem - I have nowhere near the bandwidth to download the images from someone's Vox account to my webhost and then make the WXR file use a URL off my host with the extension appended based on MIME type.

    I appreciate the suggestions from both of you jrevillini and apljdi, but it looks like I'll just have to shelve this one until Vox starts adding extensions to its images and/or WordPress starts recognizing mime types on attachment URLs.

Topic Closed

This topic has been closed to new replies.

About this Topic