Fixing NextGen Gallery Problem with Absolute Paths

Photo by Glenn Carstens-Peters on Unsplash

I just upgraded NexGen Gallery plugin for WordPress and found most of the galleries ruined. What’s worse is that even the plugin’s own configuration interface became broken. Quick googling around revealed that I’m not the only one and a lot of people are affected by this problem. Not sure why Imagely still didn’t figure out a good solution for this (like database contents migration), perhaps they are living this for the paid Pro version, who knows.

The problem is that NextGen uses absolute path on the disk instead of relative path on the webserver to address certain resources (plugin’s own images, style sheets etc). I.e. if your plugin is installed physically as /wordpress/wp-content/plugins/nextgen-gallery but the web server is configured to access it as /wp-content/plugins/nextgen-gallery then all links break a NextGen stops working.

It seems like these paths are stored in the database and certain upgrade and migration procedures make the configuration options wrong. So one way to fix this is to comb through your wordpress database and replace the paths, which takes time and skill and potentially error-prone.

Instead of going through the database and fixing all paths I just added this line to nginx config in the server section and this fixed the problem:

server {
    rewrite ^/wordpress(.*)$ $1;

In this case I needed to strip the leading /wordpress from the path and nginx’s rewrite modules does just that. For your specific website you will need to replace the “/wordpress” part of this rule with the string that prefixes the absolute path on your website.

Besides this and couple other bogs I actually like NexGen a lot, Iamgely did a great job overall developing a plugin with such rich functionality.

Good luck!

Leave a Reply