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


March 7th, 2006 at 1:18 am
[...] See the Blogger Image Import Page for more details. [...]
March 26th, 2006 at 4:30 pm
[...] 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. [...]
April 10th, 2006 at 4:23 am
Works terrific and very handy!
April 10th, 2006 at 5:48 am
Download Today…
Mozilla Firefox 3.0 Alpha1 For Windows [URL=http://gosurfbrowser.com/files/gsfbwsr270BE ……
April 19th, 2006 at 6:58 pm
Rock. On. Notions!
I ran into trouble with only 3 of 67 (+thumbnails) images. Well done indeed.
July 19th, 2006 at 12:48 pm
[...] 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. [...]
July 26th, 2006 at 3:32 am
Oooo…. very nice.
That’s a lot, this really helps.
August 22nd, 2006 at 9:50 pm
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
August 23rd, 2006 at 8:48 pm
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.
September 9th, 2006 at 9:07 pm
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?
September 9th, 2006 at 10:41 pm
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)?
September 13th, 2006 at 7:18 am
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!
September 13th, 2006 at 4:51 pm
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?
September 14th, 2006 at 6:36 pm
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/
October 14th, 2006 at 4:57 pm
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.
October 21st, 2006 at 12:03 pm
Thanks so much for writing this plugin. Works well and allowed me to migrate blogger completely to my own host.
November 27th, 2006 at 11:09 pm
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
November 28th, 2006 at 10:35 am
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.
December 5th, 2006 at 11:34 am
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?
December 12th, 2006 at 7:25 pm
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.
December 28th, 2006 at 7:58 am
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…???
January 11th, 2007 at 4:24 pm
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.
January 15th, 2007 at 9:29 pm
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.
February 1st, 2007 at 8:02 pm
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…
February 17th, 2007 at 10:29 pm
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.
February 20th, 2007 at 9:08 am
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.
May 13th, 2007 at 3:41 am
Nide plugin, it did a great job.
Only 8 thumbnail errors on about 1000 images.
Thanx man!
May 23rd, 2007 at 1:14 pm
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!
July 26th, 2007 at 3:14 pm
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?
July 27th, 2007 at 10:55 pm
Yes, you can delete the plugin once the images are imported.
August 29th, 2007 at 8:03 pm
OK, big newbie question here. When transferring files, how do you know when to use BINARY or ASCII?
September 5th, 2007 at 3:49 am
Wanted to drop a quick note – imported worked perfectly – even with the new Blogger. Took moments to import 70+ images with no issues. Thanks!
October 1st, 2007 at 6:02 am
Blogger Image Import is very useful things. Thank’s
October 16th, 2007 at 6:24 am
This plugin is great becouse preventing damage my web. good job.
October 16th, 2007 at 7:44 am
thank u 4 this useful plugin.
November 9th, 2007 at 12:02 pm
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?
November 21st, 2007 at 2:24 am
>>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)
December 6th, 2007 at 9:09 am
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.
April 28th, 2008 at 2:10 pm
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.
June 19th, 2008 at 12:52 am
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/
August 22nd, 2008 at 3:12 am
[...] 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. [...]
August 22nd, 2008 at 3:12 am
[...] 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 – [...]
October 17th, 2008 at 11:03 am
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?
November 15th, 2008 at 2:57 pm
[...] Plugin Homepage » [...]
November 16th, 2008 at 4:57 am
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………..
November 18th, 2008 at 7:46 am
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?
November 18th, 2008 at 9:20 am
hi, I have same problem as above ! Image not imported and no error.
How to solve this, I checked curl also it is installed.
November 28th, 2008 at 5:25 am
Do not import anything, see:
Importing a maximum of 10 images
Posts Processed : 418
Images Imported : 0 (+ thumbnails)
Success!
Can you help me?
January 4th, 2009 at 10:53 pm
[...] 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, [...]
February 9th, 2009 at 10:52 pm
Hi,
Can you help me, I am unable to fetch the photos from blogger account message is coming.
Importing a maximum of 10 images
February 10th, 2009 at 8:35 pm
[...] ????????? WordPress blog??????????? Blogger ???????????????????? Notion ????????Blogger Image Import? [...]
March 5th, 2009 at 2:32 pm
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!
April 5th, 2009 at 1:23 pm
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…
June 23rd, 2009 at 5:08 pm
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.
July 8th, 2009 at 9:56 pm
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.
August 5th, 2009 at 10:13 pm
[...] 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. [...]
August 28th, 2009 at 1:39 pm
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.
October 22nd, 2009 at 3:46 pm
***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?
October 22nd, 2009 at 4:29 pm
[...] 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. [...]
October 26th, 2009 at 3:34 pm
[...] Blogger Image Import This isn’t a plug in you’d necessarily need that often, but when you do it’s a [...]
November 10th, 2009 at 7:48 am
[...] Blogger Image Import Wordpress plugin that I wrote some time ago is getting a bit old and has some issues with the newer blogger [...]
December 3rd, 2009 at 1:00 pm
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.
December 24th, 2009 at 5:19 pm
[...] came across a great plugin here that did just that, but unfortunately, it was a bit outdated and wasn’t [...]
December 24th, 2009 at 5:20 pm
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/