NextGen Gallery for WordpressMU - necessary modifications
Alex Rabe’s gallery plugin for Wordpress “NextGEN Gallery” is becoming almost as popular as the integration with Gallery2 and with good reason. I run the gallery 2 integration on this blog and it means keeping both systems as well as the integration up to date. IF for whatever reason you want / need all the functionality of gallery2 this is great, but otherwise NextGEN Gallery which is still in beta (i.e. pre version 1) is quickly shaping up as a good alternative.
The best thing about WPMU (for those that don’t know) is that themes and plugins written for Wordpress often require little modification to function - so without further ado…
1. Set the default file path for the plugin so that all images are stored per blog. This function is run on activation when the tables for the plugin are created.
ngginstall.php
function ngg_default_options()
Add
global $blog_id;
Edit options line as follows
$ngg_options['gallerypath'] = “wp-content/blogs.dir/” . $blog_id . “/files/”; // set default path to the gallery
2. Remove ability for user to update the above in the blog backend
settings.php
Remove “gallerypath” from the list of fields submitted to the form - or remove the input box entirely.
3. Modify the version check
nggallery.php
Simply set if (version_compare($wp_version, ‘wordpress-mu-1.2.4′, ‘>=’)) or remove the check entirely
Note
Other changes are required
- If you want to take advantage of disk usage limits per blog and will depend on what method you are using to implement this (we’re using zspace upload quotas)
- You’ll probably also want to hide the plugin’s server status / news display.
- You may want to change / disable the “import image folder” function. Normally you won’t be allowing your users the upload access to need this function.
- The default path is displayed in various pages (such as where a gallery is created) in the backend, you may want to remove this as it probably will not be relevant for your users.
- You may need to edit / remove the permissions checking code depending on how your server is setup
- Kevin Element left a comment below to say “I noticed that when you log in as a user and use the “Uninstall plugin tables” under “setup” it deactivates the plugin for all users.” so that is another feature you’ll wish to look at modifying. Thanks Kevin
Why are you not simply releasing a version of the plugin that works with MU?
Because “works” is relative to how you intend your MU site to function and what other custom code you have installed. The above hacks are the necessary to get the plugin to work on a default MU install. Alex is planning MU support for version one of the plugin - but how best to do this is debatable especially with the addition of things like a role manager and tagging system.
The current discussion on NGGallery for WPMU is here
Rowan :: Aug.24.2007 :: Quick Solutions, Wordpress MU :: 11 Comments »










Hello Rowan,
thank you for this post…
[...] http://blog.rowancrane.com/2007/08/24/nextgen-gallery-for-wordpressmu-necessary-modifications [...]
thanks a lot for the code… =)
I was pushing the bounds of NextGen Gallery and I noticed that when you log in as a user and use the “Uninstall plugin tables” under “setup” it deactivates the plugin for all users. It may be a good idea to delete that functionality as well until we can tame it with the appropriate code.
Thanks for the great work!
Thanks Kevin, I’ve added that to the post.
This worked for me, note copying and pasting mess me up some, the quotes used in your text are different from “/files/” “/files/”. This was creating folders in my wpmu root directory, while the actual urls were fully populated site.com/blog/Gallery/pic.jpg.
Just a note
Also the “uninstall” didn’t work for me, it didn’t seem to do anything. Once I realized I had issues I had to manually deactivate the plugin and remove the appropriate db tables.
Thanks for the code.
I’ll have to look into the code to remove the setup tab for all users.
Let me also add that I’m using wordpress-mu-1.2.5, and thickbox wasn’t working in posts, the class tag was getting stripped out.
One way around this is to allow the class tag on anchors , reference this post:
http://mu.wordpress.org/forums/topic.php?id=5258&page
Worked for me.
The code for resetting to default settings and uninstalling the plugin (dropping tables) is located in: nggallery/admin/setup.php
You can edit the html printout therefore removing the forms which is what I did, or the correct way to do it would be to modify this code so that it removes the correct per blog tables: * (I didn’t edit it, I’m lazy)
if (isset($_POST['uninstall'])) {
check_admin_referer(’ngg_uninstall’);
*$wpdb->query(”DROP TABLE $wpdb->nggpictures”);
*$wpdb->query(”DROP TABLE $wpdb->nggallery”);
*$wpdb->query(”DROP TABLE $wpdb->nggalbum”);
*$wpdb->query(”DROP TABLE $wpdb->nggtags”);
*$wpdb->query(”DROP TABLE $wpdb->nggpic2tags”);
delete_option( “ngg_options” );
delete_option( “ngg_db_version”);
// now remove the capability
ngg_remove_capability(”NextGEN Gallery overview”);
ngg_remove_capability(”NextGEN Use TinyMCE”);
ngg_remove_capability(”NextGEN Upload images”);
ngg_remove_capability(”NextGEN Manage gallery”);
ngg_remove_capability(”NextGEN Edit album”);
ngg_remove_capability(”NextGEN Change style”);
ngg_remove_capability(”NextGEN Change options”);
$messagetext = ”.__(’Uninstall sucessfull ! Now delete the plugin and enjoy your life ! Good luck !’,'nggallery’).”;
}
[...] finished the first WPMU modification for NextGEN Gallery based on the changes from Rowan Crane. I’m tested this here locally and it works so far. If somebody is interested to test this in [...]
perfect work, thanks
this is great, but can the plugin active auto