Getting gallery2 to work in Drupal (embedded) can be very frustrating. This guide has been updated for Drupal 5.x and the new Drupal gallery module.
First, download the Drupal gallery module from the Gallery Project page (note that while the new gallery module listed above contains improvements over the old one, at the time of this writing it was still in beta phase, meaning it may not work), and upload the “gallery” folder into your modules directory. Don’t activate the module yet – we’ll be doing this after installing Menalto’s Gallery.
Installing Gallery2 in Drupal
Obtain the latest Gallery release by visiting gallery.menalto.com and downloading the latest release. The main difference between the versions (from typical to developer) are that the more loaded versions come with more modules, which you can always add later. Make sure the “Image Block” and “ImageFrame” modules are included (with the “typical” installation they’re not, but you can download them on the Gallery2 official modules page).
Extract the Menalto Gallery into a folder called “gallery2” inside your Drupal installation (we recommend drupal/modules/gallery/gallery2 to avoid location issues). Make sure you don’t name the directory “gallery” as this may conflict with Drupal’s gallery module. This may take a while to upload via FTP. For those that want to ensure that files don’t get lost by interrupted FTP sessions, we recommend you check out the Gallery2 Preinstaller (or make sure your FTP client resumes broken sessions – in Smart FTP this can be accomplished, for example, by clicking “Queue/ Direct Transfer” before uploading files).
(Optional) Disable .htaccess
Install Menalto Gallery
Browse to the /gallery2/install/ folder and installation should begin automatically. When you get to the step asking you where to install g2data, make sure to install it in a non-public directory (above your “public_html” or “www” folder, ie. above the root), and CHMOD the directory’s permissions to 777.
Once installation has completed, make sure you CHMOD permissions on /gallery2/config.php back to 644. In addition, create an .htaccess file within the /gallery2/ folder containing the following:
<Files ~ "\.(inc|class)$"> Deny from all </Files>
Finally, you’ll want to CHMOD permissions on your /gallery2/ folder to 555 (unwritable).
If you already have your Drupal sites setup in a multisite configuration, getting gallery2 to work with them is a breeze. Simply select “Multisite Installation” in step 3, and then type in the path (where = primary drupal installation)
where “drupal” is the directory of your primary Drupal installation (multisite codebase that other multisites run off of). Each time you wish to install gallery2 in one of your multisites you simply run the gallery2 installation from the primary path and update the URL above in step 3 to install the new multisite.
Menalto Gallery Settings
Once you have finished installing Menalto Gallery, log in and make sure “Image Block,” “Image Frame” and “URL Rewrite” plugins are installed and activated (log in to your Gallery2 installation, click on “site admin” and then “plugins”). For the URL Rewrite plugin, select “Apache mod rewrite” and CHMOD your /gallery2/.htaccess file to 666 to pass the tests. Click done if both tests are successful, and then click “activate” next to the “URL Rewrite” plugin to activate it.. If you downloaded a package below the “full” version you may need to download and install these modules separately. Finally, deactivate the “Registration” module if it is active. All registration will now be done via Drupal.
Log Out Of Menalto Gallery
Log out of Menalto Gallery before proceeding to avoid Drupal integration issues.
Embedding Gallery2 in Drupal
Install and Configure Drupal’s gallery module
Browse to site building -> modules -> list and activate the gallery and gallery menu modules. Then go to site configuration -> gallery settings -> install. If you installed /gallery2/ outside the /modules/gallery/ directory you’ll need to adjust the location settings. You’ll also want to “sync” your users (this may take a while if you have a large Drupal user database). Once everything “OK’s” enable the “gallery” blocks and you’re good to go!
Install and Configure Drupal’s gallery module
Browse to admin -> modules -> and enable the “gallery” module. Then go to administer -> settings -> gallery and enter the following:
For Single Installation
- URI of Gallery2:/modules/gallery/gallery2/
- Location of Gallery2: /home/root-name/public_html/modules/gallery/gallery2/
- Embed URI:/index.php?q=gallery
For Multisite Installation
- URI of Gallery2: /sites/multisite.com/gallery2/
- Location of Gallery2: /home/root-name/public_html/sites/multisite.com/gallery2/
- Embed URI: /index.php?q=gallery
You may leave “autodetect” selected and click “save configuration”. If for some reason the path resolves to an error but you are able to access the path via your browsers, ensure that you haven’t password protected (using “web project” in cPanel, for example) the directory. If so, temporarily unprotect it to proceed.
Getting URL Rewrite to Work
At this point everything should setup successfully but you may still receive an “Advisory” for the URL Rewrite module. This is normal, as this module needs to be configured first. Browse to admin -> settings -> gallery. Expand “Links to Gallery2 Site Admin sections most relevant to Drupal (advanced)” and click on “Embedded URL Rewrite settings.” On the next screen you’ll be specifying a new .htaccess file. I typically put this in the gallery2 directory (ie. example.com/modules/gallery/gallery2). CHMOD the file to 666, and specify the paths as follows:
Htaccess path: modules/gallery/gallery2 Public path: http://www.example.com/modules/gallery/gallery2/
If the Apache gods are on your side you should see the green message “Successfully saved settings” at top. Voila You can double-check your setup by clicking on the “test” tab. You should see a green “success” at top right indicating a successful pass of all three tests. Finally, you can now browse to “URL Rewrite” under “Admin Options” at left to configure the Rewrite settings.
Enable Drupal Gallery Blocks
Enable the “Gallery Block” in administer -> blocks, and optionally the “Gallery Navigation Block” and the “Gallery Grid Block”.
Make sure you enable access for an “all access” type profile that you are enabled for (the default admin profile may not give you access) and grant access for the gallery module to enable “access standalone g2image.”
Accessing the Gallery
Click on “gallery” in your account’s admin block to access the gallery. If it was embedded correctly you should see links to “site admin” in the top right corner, “add photo” in the center, and “edit” in the bottom left. If you don’t see these links you may be logging in with a non-administrator role. In which case you should log out, log back in as administrator, and add the corresponding users by selecting “members” next to “Site Admins” from within embedded gallery2’s “Groups” menu item. If this doesn’t solve your problem, and certain functions (such as creating an album), don’t work, check your .htaccess file for a unique situation in which you may be rewriting index files:
# rewrite index pages
#RewriteRule ^index\.(htm|html|php) http://www.example.com/ [R=301,L]
#RewriteRule ^(.*)/index\.(htm|html|php) http://www.example.com/$1/ [R=301,L]
In my situation this was interfering with Gallery2 rewrite rules. Commenting these lines out fixed the problem and I was able to edit and create albums, delete photos, etc.
Our site's mission is to help consumers make more informed purchase decisions. This post contains affiliate links (marked with 'Affiliate' when you hover over them) and we will be compensated if you make a purchase after clicking through these links. Our website accepts financial compensation to allow us to provide this free service to you, our reader, while eliminating the need to clutter pages with advertisements. Compensation does not influence the rankings of products. More info on our disclosure page.