:date: 2012-09-04 14:27 .. seealso:: * :ref:`2012-wordpress_to_octopress` * :ref:`2012-wordpress_to_octopress_audio` * :ref:`2012-wordpress_to_octopress_comments` * :ref:`2012-wordpress_to_octopress_images` * :ref:`2012-wordpress_to_octopress_videos` .. index:: tech, blogg, markdown, octopress, wordpress, ruby .. _`2012-wordpress_to_octopress_galleries`: Wordpress to Octopress: Galleries ================================= .. image:: /_images/images/gallery/2012/2012-placeholder/20120828-wordpress_to_octopress.png :alt: Wordpress to Octopress :align: right :scale: 50 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 :program:`NextGen` Gallery in the :program:`MySQL` database * :file:`wp_ngg_gallery` * :file:`wp_ngg_pictures` in order to extract the right images from the right galleries. Get them via :program:`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 :samp:`http://`. So the script will create the right syntax, but the conversion to Octopress using the :program:`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: .. code:: bash $ 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:// -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: .. code:: bash $ sed -i 's/wp-content\///g' *.markdown Some comments about the script #. If you run it without any parameters, it will give you the syntax and a small help. #. Make a backup of all what you're doing before you run any scripts. #. Current the parameter :samp:`-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.