Using Blogger Importer, I pulled content from Blogger. The posts include images embedded in the text and a small image gallery at the base of the post that was built (rather painfully) using tables.

Reading this Cheeky Monkey post, I saw that they had modified the module to aid with image import since the standard module didn't handle that well. I got very mixed results.

For some posts, the images are correctly identified and added to "field_image" as specified. For others, the images remain embedded in the text with a URL reference back to blogger.

Cheeky Monkey updated code:

      // Image downloaded successfully.
          if ($response->code == 200) {
            // Save it.
            $file = file_save_data($response->data, $filepath, FILE_EXISTS_REPLACE);

            // Save the image to the field_image now
            $node->field_image[LANGUAGE_NONE][] = array('fid' => $file->fid, 'display' => 1);

I would like to head in this direction, so that I can have better controls over the image gallery views / template. That said, I also see that the embedded images look much sharper than the images that have been saved in field_image. (Might fix that if with color box, but am not sure.)

This particular post came in with a mix of how the images were handled. The images at the top of the post are saved in field_image, while the image midway in the text and thumbnail at the bottom reference the blogger href. Here's the original post in blogger.

1 Answer 1


The issue you described with some images not importing (keeping the blogger URL) is caused by the regex not identifying the image URLs as blogger hosted images. This regex can currently be found in the same file batch.nodes.inc on line 213 :

      if (preg_match_all('/(href|src)="(http:\/\/.*?\.blogspot\.com\/(.*?))"/', $node->body[LANGUAGE_NONE][0]['value'], $matches)
      || preg_match_all('/(href|src)="(http:\/\/.*?\.blogger\.com\/(.*?))"/', $node->body[LANGUAGE_NONE][0]['value'], $matches)) {

The code that worked for me is follows :

      if (preg_match_all('/(href|src)="(https?:\/\/[0-9a-z\.]+blogspot\.com\/(.*?))"/', $node->body[LANGUAGE_NONE][0]['value'], $matches)
      || preg_match_all('/(href|src)="(https?:\/\/[0-9a-z\.]+blogger\.com\/(.*?))"/', $node->body[LANGUAGE_NONE][0]['value'], $matches)) {

This could be improved but worked for me. It allows for http and https. And the .* was grabbing too much text before an image if there was a link above the image.

For the image quality, note that blogger uses different quality of image for displaying within the post and when clicking on the image. Note the number contained within the URL s200 is low resolution, s1600 is high resolution. Other numbers could be used for different size image. You will have to decide which image to save or create a field to save two versions of each image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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