Support » Fixing WordPress » Blogger Import Pictures?

  • Is the blogger import process suppose to import pictures that are hosted on blogger.com? A friend of mine ran the importer however, the images don’t appear to be imported. The strange thing is that when you view the source for his page (http://www.theswirl.org/wordpress/) you can see that the image tag is valid however, it appears as though blogger is blocking him from displaying the images on his site.

    Any ideas?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Blogger blocks images they host from appearing on other sites. They might show up for a second, but then they won’t any longer. D’oh!

    Thread Starter raianoat

    (@raianoat)

    Thanks for the help. I found this post on wordpress.com which has a comment by Matt saying the same thing.

    http://wordpress.com/blog/2006/01/26/blogger-typepad/

    damn Blogger!

    I’ve heard rumours that there is a tool to help with this process. If anyone know any more that would be helpful since I have a lot of photos hosted on my blogger blog. Once I figure out how to get the import working (that is an entirely different problem) I will need this myself.

    It seems like it should be simple enough to do. Scan through the blog entries looking for .jpg files hosted at blogger.com, download those files (you can download them with no referrer – not embedded in a web page) to a directory in the wordpress blog and update the links. I have no idea how to do it, but someone who knows wordpress and the wordpress DB should be able to write this in no time. Anyone?

    I couldn’t find anything already done, so I have decided to write my own plugin to do this. This may take me a while. I am learning about PHP and WP plugins while I do it.

    I currently have a plugin that adds itself as an Options tab in the admin interface that, when run, outputs the URL of every jpg in my blog that is hosted by blogger. Hey, it’s a start.

    I think with some mystical use of wp_insert_attachment, add_post_meta, update_post_meta (All used by inline-uploading.php) and a variation of wp_handle_upload that retrieve the file from a URL, that I might be able to get this going.

    I want it to produce exactly the same results as if I had manually added them in the upload interface. Each image will get its own post and instead of creating a thumbnail I will simply reuse the one on blogger.

    I will release it when I am done if anyone wants it. The more interest there is the faster I am likely to complete it.

    I’d definitely be interested in checking out a plugin like that.

    Well, I have some tests working right now. I haven’t run it on my entire blog yet, but it works on single posts.

    Quick Poll:

    1. My script currently creates an image post for the images and makes that a child of the main post before linking the images (just like the image upload feature). I also have the option of turning this off. Can anyone think of a good reason to make a post for the image? I can’t even figure out how to access it without inserting a link to it in the post itself (through the image browser) and even then it is just a post with a link to the image. I am tempted to disable this for the imports since they aren’t really useful and I am not likely to want to browse them later.

    2. The script can take a while and my server times out if they take too long (I suppose I could increase the timeout on the server, but not everyone has this option). What is the best way to handle this? It would suck if the script got halfway through a post and didn’t complete because of the delay (copied the image but didn’t setup the links). I am thinking about just doing a fixed number of images at a time. This makes the whole process a little less automated unless I have the page automatically refresh if it did not complete (how?). I could also set a time limit and calculate running time (how?) so that each attempt takes no longer than 30 seconds. Any thoughts?

    3. What about the location of the images? Currently my script uses the same code as a normal image upload and inserts them into wp-content/uploads/<year>/<month> with the current date. This means that all blogger images will end up in one folder with the date of import. I was thinking about making it use similar paths to the original blogger posts or putting them all in a wp-content/uploads/blogger to identify them better. Again, any thoughts on this?

    I will publish my script as soon as I have worked out the time issues and done some more tests. I don’t want to release this prematurely and have it break someones blog.

    Okay, now I know what I need to do, I’ll just upload my missing images. It’s only about 7 or so, but wouldn’t it be better if the importer brought the images over into the new site at the same time? Especially if we’re moving our entire blog with the express intent of managing & hosting a single blog?

    Can anyone help me with my plugin?

    The biggest concern so far is that is that if the server times out while running my script it could leave things in a bad state.

    For example, I ran a test and it copied the files from Blogger to my server but timed out before it could copy the thumbnail or update the post. So if I run the script again it will make another copy of that file (carefully using a new name in case the name conflict is valid) and leave the extra jpg.

    How would be the best way to keep track of which posts have been completed and which haven’t? I was hoping to identify a completed post by the fact that it no longer referenced the blogger URL. Basically I really need the “Copy image, copy thumbnail, update post” to be atomic and correctly handle being terminated part way through.

    Thoughts?

    Just a thought Poco, but you may want to try and use concat key to keep your photos straight. Something like using the post number & date appended to the image name might help.

    Good idea – I was thinking about keeping the blogger directory structure partially intact /<some id>/<some other id>/<size>/<image>. That would guarantee that the images had unique names so if I found an image with the same name I just wouldn’t copy it again. This could help if someone had the same image linked from multiple posts.

    So I guess I will try to make the system foolproof by making sure it never does the same operation twice rather than trying to make a series of operations atomic.

    Thanks

    Okay, so now I have a more robust system for importing the images. It seems to be able to be terminated just about anywhere in the flow and I can restart successfully without any extra files lying around…

    My next question, does anyone have any suggestions for how I could make the page reload if it is accidentally terminated due to taking too long to run. I would like it to just keep reloading (but only if it fails) until it completes. I need a way to force the browser to refresh when it has finished loading the page (I can figure out the terminating condition of success).

    Well, as promissed, my plugin is now available. I have hosted it on wp-plugins.org and the description can be found here. http://dev.wp-plugins.org/wiki/BloggerImageImport.

    I have only run a few tests with this, but successfully imported my entire 96 post (300+ images) blog with this to a test server running on my PC (not a production server). In that test only one file was corrupted (I had to manually download it) and the script can only be run a few images at a time depending on your php server timeout.

    DO NOT TRY THIS WITHOUT A GOOD BACKUP OF YOUR BLOG. THIS MAKES PERMANENT CHANGES TO YOUR DATABASE AND HAS THE POTENTIAL TO COMPLETELY F@#! IT UP. YOU HAVE BEEN WARNED!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Blogger Import Pictures?’ is closed to new replies.