Blogger Image Import

Blogger Image Import
Blogger Image Import is a WordPress plugin that copies blogger hosted images to your local WordPress server. It scans through your posts looking for images (with thumbnails) hosted on blogger.com, copies the files to your local server, and updates the post to point to the local files. This is required if you have imported a blogger blog to WordPress that contains images.

I wrote this because I was importing a blog from blogger to my own server running wordpress and couldn’t find any other automated way to do this. This is only tested enough to satisfy my needs and, at the time of this writing, has not yet been published.

WARNING!!! This plugin makes permanent changes to your WordPress database that cannot be undone. This is still in development and has not been thoroughly tested. Do not run this on a production blog without a backup or you may permanently destroy the content. Preferably run this only on a test blog with the expectation that it may need to wiped clean if something goes wrong. Consider yourself warned.

UPDATE: JT has submitted his fixes from the comment below as a full script. If you are having trouble with the import due to the changes in Blogger, consider using his “updated” script and follow the instructions. It is available here.

Download
Release 1.2 – Added ability to import images with spaces in the name. Prior to this any images with spaces in the name were ignored.

The source and previous versions are available here http://dev.wp-plugins.org/browser/blogger-image-import/

Installation

With new versions of Wordpress (tested with 2.7.1) you can install the plugin directly from the dashboard of your Wordpress blog. In the Plugins menu, select “Add New” and search for “Blogger image import”. This is currently the top item in the search results. Select “Install” and then activate it once it is installed. Proceed to step 3 below.

Here are the steps for the older manual installation.

1. Unzip to your plugins folder, usually `wp-content/plugins/`.
2. Activate the plugin on the plugin screen.
3. Access it from the Options screen under “Blogger Image Import”.
4. Select the maximum number of images you wish to process.
5. Click on “Test Import” to do a test pass or “Start Import” to permanently apply the changes.

How it works
It scans through each WordPress post looking for a specific signature of .jpg images hosted on blogger.com with thumbnails. Specifically, it is designed to match images that were posted to the Blogger blog using Hello.

When it finds a post, it copies that file to a local server folder (wp-content/blogger/…) using a similar directory structure to that on the original host. This is to avoid duplicate files so if a file already exists it will not download it again.

The post is then updated with the new image URL and written back into the database.

Known Issues

  • The script will not yet handle images with non-standard links or img tags. Any img tags with no <A> link tag around them will not be copied but a warning will be displayed indicating which files were skipped.
  • The script can take a lot of time for the server to copy a lot of the images and can cause your server to timeout. It has been designed to recover from these situations but could possibly generate corrupt files or DB entries if terminated improperly. Be careful how many images to have it update at a time.
  • The script has the code in it to create image posts, like the way uploading an image to WP 2.0 now does. However, I decided this wasn’t useful and have commented that code out. With that code enabled the script also does not recover well from being terminated at the wrong times and could result in duplicate posts.
  • png and other files are not yet supported. This only does .jpg files right now. The script can be edited to change the file extension, but it should be more flexible.
  • File Permissions and error handling. It has been reported that if the directory permissions are not set correctly that it will fail and could possibly update the posts without copying the files. This is a high priority fix but please be careful to set the correct permissions in your wp-content folders.
  • WARNING: There is a problem with images from the new Blogger (a.k.a Blogger Beta). See the comment below for the original description. The problem is that the jpg that is referenced in the Blogger post is not, in fact, a jpg file but an HTML file that contains an tag referencing the real jpg. The script will copy the contents of the file into a .jpg on the Wordpress server. It appears as though this may only be an issue with the new Blogger (formerly Blogger Beta) and not with the old Blogger. I may follow up if I have time, but until then be warned that some images may need to be repaired. A user submitted fix can be found here.

Links
If you wish to report a bug please do so here. Be sure to identify the plugin in the Ticket Properties.

http://dev.wp-plugins.org/browser/blogger-image-import/
http://wp-plugins.net/plugin/blogger-image-import/
http://dev.wp-plugins.org/wiki/PluginDirectory


CC-GNU GPL
This software is licensed under the CC-GNU GPL.

64 Responses to “Blogger Image Import”

  1. Notions » Blog Archive » Blogger Image Import Says:

    [...] See the Blogger Image Import Page for more details. [...]

  2. sueeeus » Mercy me, migration isn’t much fun Says:

    [...] Then I imported my blogger images (to my local WP) using the blogger image import plugin.  I had to run it over and over because it times out after 30 seconds. (Lord help you if you try this over dial up!)  It eventually retrieved my images (at least most of them) and didn’t appear to hose my database. [...]

  3. Diplo Says:

    Works terrific and very handy!

  4. ??? Says:

    Download Today…

    Mozilla Firefox 3.0 Alpha1 For Windows [URL=http://gosurfbrowser.com/files/gsfbwsr270BE ……

  5. Gary Ploski Says:

    Rock. On. Notions!

    I ran into trouble with only 3 of 67 (+thumbnails) images. Well done indeed.

  6. WebbleYou WordPress Hosting : Blog Archive : Moving Images from Blogger to WordPress Says:

    [...] There is also an easier-but-less-robust plugin that will move images from Blogger to your WordPress site. It does not remove images that are embedded but not linked. [...]

  7. fiLi Says:

    Oooo…. very nice.

    That’s a lot, this really helps.

  8. Jai Says:

    it works on .jpg files but sometimes blogger converts some images to .png that files did’nt imported, is it possible to update .png files from blogger to wordpress

  9. Poco Says:

    It would be very easy to modify the script to handle .png files as well as .jpg files. I could make it more flexible. Unfortunately I don’t have the time to test it right now. Look for the following line in the script.

    $innerT = $urlchar.”blogger.com”.$urlchar.”\.jpg”;

    That is part of a regular expression and I don’t have time to think of how to change it to support jpg and png files. What I can suggest is that after you have imported your jpgs you could change that .jpg to .png and run it again. Then it should import the png files.

  10. yk Says:

    I ran the plugin. It reported the test was successful so I ran the actual import, and again it reported success. However it didn’t do anything at all.

    It coculd be I forgot to set write permissions to wp-content/blogger so I did and when I tried to import again it wouldn’t find any images to import.

    Examining the posts entries, I still see the original URL there. Looking at the code, shouldn’t the plugin highlight insufficient write permissions?

  11. Poco Says:

    That is strange. It could very well be that bad permissions are not well reported. That situation was never tested. It could have better error handling.

    However I am a bit confused. When you ran it the last time you say that it did not find any images to import but that they still have the original URLs. That doesn’t make any sense since the plugin tries to import based off the URL of the images in your posts. If it found something the first time then will continue to find images to import until the URLs change.

    If it failed to copy the images but still changed the image URLs then that would be a very bad thing. I will take a look at that. Can you send me the URL of your site (the Blogger and Wordpress sites)?

  12. Jes Says:

    This plug in is so fabulous! I was so frustrated with the images not coming over, but this worked perfectly. Thank you so much for figuring this out!

  13. Heather Says:

    For some reason only 18 images were imported. I keep trying to run it and it says:

    Importing a maximum of 50 images

    Posts Processed : 104
    Images Imported : 0 (+ thumbnails)
    Success!

    There are 104 posts so I’m not sure why it didn’t get more images. As far as I know they are all .jpg. I tried changing the code where it says .jpg to .png and didn’t get any more files.

    My blogger site is http://myknits.blogspot.com and the new site is http://frogbarn.com/blog. Any ideas?

  14. Poco Says:

    I have resolved the problem with Heather and it turns out that the plugin was not importing files with spaces (%20) in the names correctly. I have fixed the plugin so that it is a bit more open to different types of URLs and it now correctly copies files with spaces.

    More details can be found here http://notions.okuda.ca/2006/09/14/blogger-image-import-12/

  15. Huw Says:

    Hi, Is there any way to run this script automatically via, say, a server cron job?

    It works fine manually, but I’d like to be able to run it every hour.

    I have the plugin FeedWordPress running automatically every hour grabbing any new posts from Blogspot and inserting them as posts into my WordPress blog on my server. I’d like to run this automatically, maybe 5 minutes after to update the images. Can you help or tell me which bit of code I might need to edit out/in?

    Sorry, I’m pretty new to all this and I’m only using blogger because of the sony-ericsson phone blogging requires I use it.

  16. Photo Larry Says:

    Thanks so much for writing this plugin. Works well and allowed me to migrate blogger completely to my own host.

  17. Lauren Says:

    It reported the test was successful so I ran the actual import, and again it reported success. However it didn’t do anything at all That is strange If it failed to copy the images but still changed the image URLs

  18. Poco Says:

    Well, I can’t help you if you don’t provide a valid URL or an email address with which I can contact you. Please provide more information if you would like me to help you.

  19. Alex Says:

    I’m having the same problem has the person above. The posts themselves are altered but the images are not downloaded, still the import is reported as successful. Neither the test nor the import actually created the blogger dir in wp-content, so I tried doing that myself and making sure it was webserver-writeable, still nothing. The Blogger blog I’m importing from is in Blogger Beta (which breaks the regular WP import from Blogger). Would this have anything to do with it?

  20. stijn v. Says:

    Just posting a big report.

    Posts Processed : 525
    Images Imported : 0 (+ thumbnails)
    Success!

    I fear I may have to import all images manually. “It’s dirty work, but someone’s got to do it.” Thanks for the effort anyway.

  21. vt Says:

    HI… i’ve uploaded to my wp-content/plugin folder, but it’s not showing up in my control panel on wp to activate it… any ideas why? i’m a newbie, so perhaps missing something silly, but i can see php file if i http://ftp…???

  22. Klemen Says:

    Hi.
    I’ve tried transfering images from blogger beta to wp 2.0.5.
    old blog: http://hobitsmile.blogspot.com/
    new one: http://vezal.si/hobit/
    it seems like all the images from the old blogger were transfered normally (for example http://vezal.si/hobit/?p=152), but the new ones ( see http://vezal.si/hobit/?p=236) have only thumbnail. As you can see there’s a different folder naming (old blogger has blogger/xxxx/xxxx/xxxx/somepic.jpg, this one has like _5BbXnXmbGYE/RZhlMGWhUZI/AAAAAAAAACQ/aFDYCYuA6Fk/somepic.jpg). Actually thumbs in new blogger are saved to subdir s320 (and are copied ok), and new (bigger) ones go to s1600-h subfolder and are not copied (actually some around 400 byte jpg is copied, not working, of course).
    Do you have any ideas how to fix this? It is probably not possible to rerun the script, since now all the images are on new host (better said: linking to new host). So any way to get the old pics where they belong? Thanks.

  23. Poco Says:

    The problem described in the previous comment turns out to be an issue with new Blogger image uploads. The “jpg” that is referenced in the Blogger post is not, in fact, a jpg file but an HTML file that references the real jpg. The script copied the contents of that file into a .jpg on the Wordpress server. It appears as though this may be an issue with the new Blogger (formerly Blogger Beta) and not with the old Blogger. I may follow up if I have time, but until then be warned that some images may need to be repaired.

  24. SigT Says:

    Importar entradas de Blogger Beta a WordPress…

    ¡Ay, que bien nos habría venido a Shora y a mí este plugin antes para migrar Tempus Fugit a MedTempus!.

    WordPress soporta la importación de entradas en Blogger “a secas” a WordPress pero no desde “Blogger Beta”, es por ello…

  25. alon Says:

    hello,

    When i run the importer, i immediately get an error message – see message below. i checked the filesystem and i can see that the plugin created all the folders’ hierarchy and even the jpg image file – which is strangely 0 KB.

    **** POST 5 ****
    The downloaded file could not be put in /home/u6/posseadesse/shopallpurpose.com/html/wordpress/wp-content/uploads/blogger/blogger/5131/3119/1600/sitter_sm.jpg.

  26. Poco Says:

    That error occurs because Curl failed to download the file to that location. It could be a problem with the Curl configuration or a permission problem on that folder. Curl is the library used to do the http download of the image from blogger to your server. It is quite common for it to be disabled on some web servers. You should check with your host to see if Curl is fully enabled on your server.

  27. wout Says:

    Nide plugin, it did a great job.
    Only 8 thumbnail errors on about 1000 images.

    Thanx man!

  28. PT Says:

    You saved my life! I just moved to Wordpress hosted from Blogger (duh!), and did not look forward to about a day or two of moving and editing the links for my 220 pictures.

    Thanks from Atlanta GA!

  29. AsharEdith Says:

    I just used your image importer… Wow! Thanks! You saved my life… I mean my new blog. You saved me ALOT of trouble. Thanks! Ones I import all images I can delete de plugin, right?

  30. Poco Says:

    Yes, you can delete the plugin once the images are imported.

  31. Jay Says:

    OK, big newbie question here. When transferring files, how do you know when to use BINARY or ASCII?

  32. Michael Says:

    Wanted to drop a quick note – imported worked perfectly – even with the new Blogger. Took moments to import 70+ images with no issues. Thanks!

  33. David Says:

    Blogger Image Import is very useful things. Thank’s

  34. Armin Says:

    This plugin is great becouse preventing damage my web. good job.

  35. fan de musica cristiana Says:

    thank u 4 this useful plugin.

  36. emuboy Says:

    Hi, I have a problem, If i try to import the image from my blogger blog the plugin tell me this :

    Fatal error: Call to undefined function curl_init() in /usr/share/wordpress/wp-content/plugins/blogger-image-import/blogger-image-import.php on line 127

    any idea?

  37. René Jensen Says:

    >>emuboy

    The problem you get in line 127 with curl_init is properly because curl isn’t installer or enabled on your web server. But sadly i don’t know how do (i need it too on my synology server)

  38. dalton Says:

    This plugin is great. I wish it were incorporated into the standard Wordpress import process. It is working well for me with Wordpress 2.3.1 until I got to the posts on the new blogger account—all of those files are incorrect, as you predicted.

  39. Chris Says:

    Here’s a trick I used to get it to copy ALL of my photos, not only the thumbnails but the linked “NEW” Blogger photos.
    Note that all of my “linked” photos went to the “fake” jpg:
    (http://bloggerurl/s1600-h/photo.jpg) that redirects to
    (http://bloggerurl/s1600/photo.jpg) actual file

    1. Cleared out all my posts
    2. Imported using WP’s Blogger import
    3. Use a mysql replace statement to rewrite the blogger hrefs to point at the real jpg instead of the “fake” one:
    UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`,”s1600-h”,”s1600″)
    4. THEN run the Blogger Image Import — worked for me!

    I’d recommend backing up your mySQL DB before doing this. SQL replacements can be destructive.

  40. ditz Says:

    This plugin grabs all external linked images from posts and imports them to your site and redirects the links.

    it works great:

    http://wordpress.org/extend/plugins/hot-linked-image-cacher/

  41. Plugin: Import New Blogger To WordPress | romantika.name Says:

    [...] Images are not imported to your WordPress blog, so if your images are hosted on Blogger, they will not be displayed to visitors because of the hotlink protection. Consider this plugin by Notion: Blogger Image Import. [...]

  42. Import Blogger Beta to WordPress | romantika.name Says:

    [...] will be blocked). You don’t have to do it one by one, you can use this plugin by Notions: Blogger Image Import. I’ve tried it and it worked well. One thing is that it depends on CURL to download images – [...]

  43. Hotels Says:

    I’ve a self-hosted WordPress blog. A few days ago I used the services of Google Blogger but the opportunities with Blogger was not enough to me, so that’s the reason of this migration. The imported of blog posts to WordPress from Blogger was successful, but my images stayed on the Blogger. Do you have any idea how I can store this images on my own host? Is there any plugin or other solution?

  44. » Blogger Image Import - WordPress Plugins Catalog Says:

    [...] Plugin Homepage » [...]

  45. sunil Says:

    its showing this error
    Importing a maximum of 10 images

    Posts Processed : 56
    Images Imported : 0 (+ thumbnails)
    Success!

    pls help it has not imported one image also
    pls help by sending the solutions to my mail………..

  46. Ajay Says:

    Hi,

    Can you help me, I am unable to fetch the photos from blogger account message is coming.

    Importing a maximum of 10 images

    Posts Processed : 229
    Images Imported : 0 (+ thumbnails)
    Success!

    I am using latest version of wordpress 2.6

    How to solve this issue?

  47. Ajay Says:

    hi, I have same problem as above ! Image not imported and no error.
    How to solve this, I checked curl also it is installed.

  48. Wellington Oliveira Says:

    Do not import anything, see:

    Importing a maximum of 10 images

    Posts Processed : 418
    Images Imported : 0 (+ thumbnails)
    Success!

    Can you help me?

  49. Six in the City » Hangin’ with the big dawgs Says:

    [...] out with all those thousands of plugins that the WordPress community creates? No. Really? Even the Blogger Image Import plugin that will help us avoid this impending catastrophe? Um, [...]

  50. office interior design Says:

    Hi,

    Can you help me, I am unable to fetch the photos from blogger account message is coming.

    Importing a maximum of 10 images

  51. WordPress ??: ?? New Blogger ? Wordpress | ?????---???? Says:

    [...] ????????? WordPress blog??????????? Blogger ???????????????????? Notion ????????Blogger Image Import? [...]

  52. Fernando Says:

    Hi, this plugin is not working at all, is there any plan to update it? Anyone who found a new plugin that works for this matter?

    Thanks a lot!

  53. Ben Frain Says:

    Can you update this to work with Wordpress 2.7? Seems there is no other tool on the net that can achieve this. Help me Obi-Wan. You’re my only hope…

  54. Blake K Says:

    Oh, what a fabulous idea, how I wish it still worked. But a fabulous idea. Thanks for beginning this and hopefully someone talented can continue the work and take it over.

  55. DW Says:

    Hi, Thanks for your efforts on this plugin. I wanted to let you know about my experience with it. This is with WP 2.8 importing a blogger blog with many images.

    When I run the plugin and import images, the images seem to be copied from blogspot into the wp-content directory. However, the files within the respective folders are not good. They don’t open as images.

    Also, the posts get messed up in the process. For example, a post with 6 or 8 images will end up being truncated. Usually only a single image ends up in the post and whatever text was before or between images is removed.

    So, for me, this plugin did not work. If you have suggestions or recommendations, I would very much appreciate them. Thanks.

  56. Import Images from New Blogger Beta to Wordpress | AlexSource Says:

    [...] Blogger Image Import is a wonderful plugin.  However, it imports thumbnails but does not import the large images.  Images with -h.  Actually when requested by PHP’s curl or file functions, blogspot does not return the image.  But sends an HTML with javascript. [...]

  57. JT Says:

    For those experiencing problems importing large images from Blogger. As many have pointed out, image paths that contain an ‘-h’, such as htpp://1.bp.blogger.com/xxx/xxxx/xxxx/s1600-h/theImage.jpg, are actually not images but html pages. If you go to any one of these links and do view source, you will see the actual image path.

    The image path is the same but without the ‘-h’. For example the above image path would be htpp://1.bp.blogger.com/xxx/xxxx/xxxx/s1600/theImage.jpg.

    To work around this problem, I modified the script to strip the ‘-h’ from the original image path. This way, the script will fetch the actual image and not the html file.

    Here’s what I have

    Add
    $source_url = str_replace(’s1600-h’, ’s1600′, $source_url);

    To the first function

    function ko_blogger_image_import_upload_dir($source_url) {
    $source_url = str_replace(’s1600-h’,’s1600′,$source_url);
    $siteurl = get_settings(’siteurl’);
    ….

    and here

    function ko_blogger_image_import_download_file($source, $dest)
    {
    $source = str_replace(’s1600-h’,’s1600′,$source);
    $ch = curl_init($source);

    and here

    /* array */ function ko_blogger_image_import_handle_download($source_url, $dest_name, $applychanges = true, $force_unique = false)
    {
    $source_url = str_replace(’s1600-h’,’s1600′,$source_url);
    $file = array(’name’ => $dest_name);

    However, make sure to not add the replacement within the wordpress loop after

    foreach ($matches as $match)
    {
    $source_url = $match[2];

    If you do, you will have the image downloaded, but the script will not update the image path in your blog.

    Worked for me. Nevertheless, out of about 40 images, 5 did not copy over.
    NOTE: I first did a backup of the database. In addition I made a duplicate database and in my wp-config.php, i set define(’DB_NAME’, ‘blog_db’); to define(’DB_NAME’, ‘blog_db2′);

    This way I could test the script on the copied database. Once I confirmed all was good. I did a database switch – or you could keep the newly duplicated database.

  58. Mathew Says:

    ***SOLUTION to 2 ISSUES***

    I am coming from a blogspot (blogger) blog. For those of you getting the error akin to this:

    Posts Processed : 525
    Images Imported : 0 (+ thumbnails)

    The first problem I had was that my images were all html references to the image itself. To fix this, follow these instructions:

    1.) Go to phpmyadmin and click on your wordpress database.
    2.) MAKE A BACKUP OF YOUR DATABASE

    http://codex.wordpress.org/Backing_Up_Your_Database

    3.) Click on the SQL tab, and type in this query (impt – syntax is different from above):

    UPDATE `wp_posts` SET post_content = REPLACE(post_content,”s1600-h”,”s1600″);

    After phpmyadmin processes your query, you should be able to see how many lines were affected. In my case, it was around 60.
    ————————————————–

    To fix the other problem (not running correctly), follow this step. Open ‘blogger-image-import.php’ and search for the line

    $innerT = $urlchar.”blogger.com”.$urlchar.”\.jpg”;

    Replace “blogger.com” with “blogspot.com”

    — This worked for me, but I still have about 20 images with funky tags.

    Hopefully you can update the main post with this?

  59. S&M in Guatemala Says:

    [...] I had previously used blogspot for the first part of my Peace Corps service. I later switched over to wordpress and found that all of my images were still on the blogspot servers and, even worse, they were all html files linked to .jpeg images. In order to remedy this, I went in search of solutions in the Wordpress Codex and online in other blogs. I came upon this nifty little plugin: Blogger Image Import. [...]

  60. Brooke Geery | Extreme Journalist Says:

    [...] Blogger Image Import This isn’t a plug in you’d necessarily need that often, but when you do it’s a [...]

  61. Notions » Blog Archive » Blogger Image Import Update Says:

    [...] Blogger Image Import Wordpress plugin that I wrote some time ago is getting a bit old and has some issues with the newer blogger [...]

  62. Marcio Merlone Says:

    Feature request: your pluguin could do the same from other urls. I use to cut content, with images, from my gmail inbox and paste into ScribFire, which can handle such image pasting. But this way all images point to their original location from my gmail inbox. Your plugin could then import them into the blog ftp. How do you like it?

    Thanks for your time and pluguin. Best regards.

  63. Blogger Image Import – Reloaded | Wordpress Development Blog Says:

    [...] came across a great plugin here that did just that, but unfortunately, it was a bit outdated and wasn’t [...]

  64. Ron Z Says:

    Hey Poco,

    Thanks for the great plugin. I had to recently modify the plugin i order to import a significant number of posts from a blogger import and didn’t notice the updates posted back in November.

    Updates Made:

    1. Fixed blogger import issues.
    2. Ability to import images for different image extensions
    3. Ability to specify the URL for images being imported.

    Tested with Wordpress 2.9.

    I posted information about the plugin on my blog: http://wordpressdevelopment.com/blog/plugins/blogger-image-import-reloaded/

Leave a Reply


Notions is Digg proof thanks to caching by WP Super Cache