Wordpress to Octopress: Galleries

Wordpress to Octopress

One of the plugins I used on Wordpress for managing the pictures was NextGen Gallery. It offered me a good way in keeping pictures manageable and made it easy to put them into galleries.

When moving to Octopress this is a luxury you don’t have anymore. And suddenly you find yourself with a tricky problem as well: you need to get your images out of there.

I’ve written a small Perl script for doing this automatically.

The script needs the exported tables from the NextGen Gallery in the MySQL database

  • wp_ngg_gallery

  • wp_ngg_pictures

    in order to extract the right images from the right galleries. Get them via phpmyadmin or something similar and export for them for Excel.

Almost after finishing the script I wanted to use the photo-tag plugin from Tritarget as well and added this to the script.

Unfortunately it currently seems that the script doesn’t support URL with a leading http://. So the script will create the right syntax, but the conversion to Octopress using the NextGen-plugin will fail.

I therefore went currently the way of using the plain fancybox syntax to migrate the galleries and will come back to this later.

I ran the script basically like this:

$ for i in `ls -1 *.markdown`; do
  ngggallery2fancybox.pl -i ${i} -g ./ngg_export/wp_ngg_gallery.csv -s ./ngg_export/wp_ngg_pictures.csv -o ~/blog_output/  -a http://<imageurl> -f f;
done

I have the images not at the same location as I have the blog, so I need to provide a full address for the images and not a relative one.

After running the script a simple _sed_ fixed the last mismatches with the file URLs. Im my case:

$ sed -i 's/wp-content\///g' *.markdown

Some comments about the script

  1. If you run it without any parameters, it will give you the syntax and a small help.

  2. Make a backup of all what you’re doing before you run any scripts.

  3. Current the parameter -r for removing a string from your image path doesn’t work properly. I reached my goal by using _sed_ (as mentioned above). Feel free to fix that.

Everything else should work and help you to get your galleries out of NextGen.