Shampoo is a very simple photo gallery script that doesn't require a database.
The gallery is built using the existing directory structure, where thumnails are created and stored by the script.
The HTML produced is minimalistic, semantic and template-based.
Unobtrusive JavaScript is used for progressive enhancement and can be removed entirely with no loss of functionality.
You can add captions and album descriptions using a very simple text file.
For a demo, visit my photo gallery.
» Download (54kB) Contents of the archive
Your server needs to run PHP 5+ and it must understand .htaccess files because mod_rewrite is used to make nice URIs. This is pretty standard and the vast majority of commercial web hosts will have no problem with this.
In order for thumbnail creation to work, your server will also need to have GD installed. Again, any host worth its salt will have GD installed.
BSD-style license. This means you can pretty much do whatever you want as long as you give due credit.
If you have trouble viewing individual albums or images, it is most likely a problem with mod_rewrite and your .htaccess file (in the base directory of Shampoo).
RewriteEngine on
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/?[^/]+$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/?[^/]+/\d+$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond $1 !^/?[^/]+/thumbs(/.*)?$
RewriteRule ^/?(.+)$ index.php?fish=$1 [L]
Options -Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/?[^/]+$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/?[^/]+/\d+$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond $1 !^/?[^/]+/thumbs(/.*)?$
RewriteRule ^/?(.+)$ index.php?fish=$1 [L]
Options -Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/?[^/]+$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/?[^/]+/\d+$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond $1 !^/?[^/]+/thumbs(/.*)?$
RewriteRule ^/?(.+)$ index.php?fish=$1 [L]
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/?[^/]+$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/?[^/]+/\d+$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond $1 !^/?[^/]+/thumbs(/.*)?$
RewriteRule ^/?(.+)$ index.php?fish=$1 [PT]
mod_rewrite is the most likely issue, especially if you are using a subdomain or if you know you are using mod_alias. If your filesystem is very different to the URI structure, then it is also likely you will need to use a RewriteBase directive.
The single / is most commonly needed when RewriteBase is required, but some hosts (e.g. 1and1) might require the path too. For example, if your base directory is called "pictures":
RewriteBase /pictures
If your host supports PHP 4 and PHP 5, but it defaults to PHP4, you need to add this right at the top of your .htaccess:
AddType x-mapp-php5 .php
If any of these turn out they work out for you, I'd like to hear about it.
If the steps above didn't help, if you encounter bugs or if you have any other questions, email me:
r [at] this domain
I had some problems with mod_rewrite but using RewriteBase fixed it.
Its a very nice gallery, thanks!
Is it possible to have categories and sub-albums? This would be very nice.
No, though I might implement this in the future if I feel the need.
I'm just a n0ob building first PHP but this looks perfect for what I have in mind! Problem during setup for me(I'm using WAMP for dev) was fixed after enabling
allow url includein PHP settings.Interesting. You only need to enable
allow_url_includein php.ini if you're using full-length URIs in your include() functions. Are you sure you need to be using them?Sub Galleries would be very nice. I have multiple folders for each client, each of which have sub-folders.
Thanks, Nice Script!
Just my opinion, but I'd prefer not have Sub Galleries and Categories (or be able disable them easily.) I chose to use Shampoo because I was looking for something really simple to host images for just 1 user: me.
BTW, I enabled
because I was using the url I specified in my hosts file to access gallery (i think ;-D)
I have started to look at a way to neatly add sub-gallery functionality, mostly because now I would like it myself.
In keeping with the current system, they would be "activated" only if the directory structure so dictates, with a potentially unlimited depth of subgalleries. Or perhaps the depth would need to be limited (to, say, 2 or 3).
The most important thing is not to lose the simplicity of the system, so it is not going to change particularly spectacularly.
I want to limit the size of my pictures in album listing but I don't know how.
Can someone help to modify this setting?
Do you mean the thumbnails? They are the same size as the thumbnails when you open an album.
This is controlled by the
$thumbmaxwidthand$thumbmaxheightvariables in settings.php.If you mean the full-size images that appear in the lightbox in the album listing, then I'm afraid the size of full-size images is up to you to control.
In the future I'm going to add a module to allow better control of the settings, and to upload images via a form. This will make limiting the size of uploaded images possible.
I want to limit the width and height in album full listing.
For example in your albul your extif show 6.1 camera like mine, but your photos are 1200x900(mine are 3000x2000 something like this). So all I can do is to modify all the pictures manually?
Suggestion/How-to-do-this: Make the image itself a 'next' button link in full size view? (eg; in this page from the demo gallery, clicking the photo would advance to the next one, -like facebook galleries as I recall.)
Also, I'm not sure but I think I was having trouble with folders with bad characters in the names working with Shampoo. (eg; Danny's Surprise! Party) Fixed with a
somewhere?
@Johnny: I've settled on a 900px width for my gallery. I use Picasa for managing my pics, and there's a handy export function for resizing for web. You could also batch resize/optimize for web with Photoshop or FastStone Image Resizer (free) off the top of my head. Hope that helps.
@ Johnny: Yes, you will have to modify the pictures manually. If not, there would be two solutions:
- Resize the images on the server. This would preserve the quality of the image. However, I would have to know what size the user wants, and people have different requirements.
- Resize the image with CSS. Very easy, but the quality of the image is vastly reduced, and it means the user is downloading an unnecessarily large image.
The easiest thing is for you to do it yourself. This is pretty easy with something like IrfanView, which can batch-process them all in one go (e.g. make the longest side in all images 900px long).
@ Danny: Yes, I've thought about doing that too, like facebook. About the folders with characters like that - they shouldn't really be there, as they should really not be a part of the URL. If you want to have a ! in your album title, that should be defined in the index.txt file.
hello!
Im trying to translate the script into swedish but at some places special swedish characters, such as Å, Ä, Ö, wont work. not even the 'html'-code for them work(å and so on).
any comment on this?
Also is it possible to make the script allow those characters in the images filenames? currently the image wont show at all with any characker like that present.
//thanks!
Having issues with the mod_rewrite, I think. Getting the "This Virtual Directory does not allow contents to be listed" when opening folders. Individual images work fine. I don't see a mod_rewrite option in the php.ini file to enable. I'm running IIS 6 if that makes a difference. I tried all of the different options for the htaccess file but nothing is working. Any thoughts? I really like this script and want this to work ... good job!
Regarding use of "foreign" characters
It was a simple solution, just calling utf8_encode on the string buffer before outputting it. I also fixed a couple of very minor mistakes (language-based). The zip file has been updated, but the only change was in functions.php, so you only need to copy that file.
Very important: The index.txt and the text files that contain the image captions must be saved as UTF-8 if you intend to use characters outside of ISO-8859-1.
MJ:
You don't need to enable mod_rewrite in php.ini, the .htaccess file should be enough. I'm not sure what the problem is because so far any mod_rewrite problems that affected folders would affect individual images too. You're sure the individual image page is showing properly, with the URI showing the path to the image?
I know nothing about IIS I'm afraid. mod_rewrite was written for Apache, so there could be some nasty incompatibility. I'd suggest doing some research into compatibility between mod_rewrite code and your version of IIS. I'm sure there's a forum for IIS where you could ask your question.
Please let me know if you find the answer, I'd very much like to know.
Raphael:
Yep, the individual photos work but they are in the pop up, of course, or iframe? And I can click through all of them in that window. Only the "open album" gives me the error. I did start to look for IIS info about it so I'll let you know what I find. I'm glad to know I can stop looking at the php.ini file. Thanks!
MJ:
Ah, of course, that popup is simply javascript-powered, so in that case your issue is almost certainly to do with mod_rewrite not kicking in.
I imagine there is some option that isn't working. I just wish it was simpler and there was some magic configuration that made it work on all servers.