Shampoo: a simple PHP photo gallery

Shampoo is a very simple photo gallery script that doesn't require a database.

Shampoo screenshot Main page, showing all albums

The gallery is built using the existing directory structure, where thumbnails are created and stored by the script.

The HTML produced is minimalistic, semantic and template-based, so the gallery is easy to build into existing websites.

Unobtrusive JavaScript is used for progressive enhancement and can be removed entirely with no loss of functionality.

» Download (450kB) – changelog

Latest version: 0.7 (19/04/2011)

Demo (my photo gallery also uses it, of course!).

Requirements

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.

Instructions

Shampoo screenshot Single album view

  1. Extract the archive (shampoo.zip) into a directory on your server.
  2. Make new albums by making new directories under the one where you extracted everything.
  3. Put pictures in these albums and Shampoo will take care of everything else.
  4. That's pretty much it. To see it, simply point your browser to the directory (index.php is the thing to run). For example, if you've put the gallery in the root of your domain, just go to http://www.mydomain.com/shampoo/ (or whatever you called the directory).

Admin interface

Starting with version 0.6, an admin interface is included. It is entirely dependent on JavaScript and is implemented as a "layer" of functionality on top of the gallery. It allows you to upload pictures and edit things directly in the browser thanks to the contentEditable capabilities of modern browsers.

If you use Firefox or Chrome you can upload multiple images at once, including via drag-and-drop from your computer. You can try it out in the demo.

Manual control

If you don't like the admin interface, you can still edit album descriptions, album titles and other settings directly in index.txt and settings.php (instructions within them). Naturally you can also upload pictures and videos by direct FTP upload.

To add captions manually, it's best to illustrate by example. Let's say you have an album (directory) called "lemurs" containing pictures from your holiday in Madagascar. Some of the pictures you want to add captions for are called "lemur1.png" and "myfavouritelemur.jpg". What you have to do is create a file called "lemurs.txt" (same name as the directory) and put the following in it:

lemur1.png|Who would've thought lemurs could do handstands!
myfavouritelemur.jpg|Really, out of all of them, this one was my favourite.

Hopefully you can discern a pattern from that. Blank lines in the file are ignored.

Passwords

You can lock albums so they can only be viewed with a password. Currently the admin interface is the only way to do this, they are no longer stored as strings in settings.php as they were in older versions. To set a password, open the album and click the "Add a password" link at the top.

The admin interface is also accessed via a password. When you first run the gallery, you will be asked to choose it. There on after you log in via the "Admin" link at the bottom of the page.

Embedding it in your website

Shampoo runs off a template file, shampoo.inc. You can add any PHP or HTML to it to make the gallery fit in with your website.

The CSS is all contained within shampoo.css and should not interfere with your website's existing CSS.

Video support

The gallery can display FLV and MP4 videos (i.e. video formats supported by the Flash plugin). Flowplayer is the player used, and is included with Shampoo so you don't have to do anything.

This is for video files placed in the gallery, like images are – not for displaying YouTube or Vimeo videos. Of course if you've downloaded the YouTube video as an MP4 or FLV and you've put it in your album, then that will of course work.

FFmpeg

Video thumbnail - panda.flv Alternate video thumbnail

In order to generate thumbs for each video you put in an album, FFmpeg has to be installed on your server. It will make the thumb from the first frame of the video. If FFmpeg is not present, an alternative thumbnail will be generated (see image).

If you don't have FFmpeg, it's straightforward to install if you have shell access. I followed these instructions, which should work for any host.

You might need to change the path to FFmpeg specified at the top of shampoovideo.php to the correct path on your server (I can't help with this).

License

BSD-style license. This means you can pretty much do whatever you want as long as you give due credit.

Problems?

Shampoo screenshot Single image view

Trouble viewing individual albums or image pages

This is most likely a problem with mod_rewrite and your .htaccess file (in the base directory of Shampoo).

  1. Check that mod_rewrite is enabled on your server. This can be achieved via phpinfo or by asking your host.
  2. Open .htaccess in your text editor. Try uncommenting some of the lines at the top, which may help (particularly the RewriteBase directive).

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 this right at the top of your .htaccess (uncomment it):

AddType x-mapp-php5 .php

If any of these solutions work for you, or you have a different one, please let me know.

Images not showing

If your image filename contains non-Latin characters (e.g. Scandinavian letters like "å", "æ" and "ø") Apache may have trouble finding them, particularly on Linux (this doesn't seem to be a problem on Windows).

The solution is to simply not use those characters for the filenames and instead use them only in the images' captions.

Forgotten password

If you forgot the password for an album, just delete the password (on the album's page) and create a new one.

If you forgot the admin password, you need to delete the file called .pw, which will be in the base directory of Shampoo. Then visit the gallery and you will be asked to choose a new one.

Contact

If the steps above didn't help, if you encounter bugs or if you have any other questions, email me:

r [at] this domain

Comments (138)

Newest first Oldest first Page 1 of 7 Next 20 »

  1. kidrock's avatar kidrock

    I'll call back later allegra x-15r centrifuge error care professionals to obtain

    #138 – 15 May, 2013 at 10:23 am

  2. kidrock's avatar kidrock

    I'll call back later allegra x-15r centrifuge error care professionals to obtain

    #137 – 15 May, 2013 at 10:21 am

  3. kidrock's avatar kidrock

    I'll call back later allegra x-15r centrifuge error care professionals to obtain

    #136 – 15 May, 2013 at 10:20 am

  4. kidrock's avatar kidrock

    I'll call back later allegra x-15r centrifuge error care professionals to obtain

    #135 – 15 May, 2013 at 10:19 am

  5. Alexis's avatar Alexis

    I'd like a phonecard, please albuterol sulfate 2.5 mg 3ml via san American woman walking around topless. Please don’t think you are restricted

    #134 – 15 May, 2013 at 10:16 am

  6. Alexis's avatar Alexis

    I'd like a phonecard, please albuterol sulfate 2.5 mg 3ml via san American woman walking around topless. Please don’t think you are restricted

    #133 – 15 May, 2013 at 10:15 am

  7. Alexis's avatar Alexis

    I'd like a phonecard, please albuterol sulfate 2.5 mg 3ml via san American woman walking around topless. Please don’t think you are restricted

    #132 – 15 May, 2013 at 10:15 am

  8. Cameron's avatar Cameron

    perfect design thanks atorvastatin generic drug lipitor approaches to approaches to treatments of treatment details rationales and

    #131 – 15 May, 2013 at 10:10 am

  9. Leslie's avatar Leslie

    I'm training to be an engineer topamax generics Name (Last, First) Dates in Eldoret

    #130 – 15 May, 2013 at 10:01 am

  10. Leslie's avatar Leslie

    I'm training to be an engineer topamax generics Name (Last, First) Dates in Eldoret

    #129 – 15 May, 2013 at 9:59 am

  11. Audrey's avatar Audrey

    What sort of music do you like? hidden lolita pics Great video of the extremely sexy Laura Lion getting anal fucked in the ass, except for the fact that the audio was way off as it did not match the visual!

    #128 – 8 May, 2013 at 5:37 am

  12. dating site for people with disabilities's avatar dating site for people with disabilities

    My brother suggested I may like this web site.

    He was totally right. This post truly made my day.

    You can not consider just how much time I had spent for this information!

    Thanks!

    #127 – 19 April, 2013 at 1:56 pm

  13. lev test's avatar lev test

    Now I am going away to do my breakfast, after having my breakfast coming yet again to read more news.

    #126 – 4 March, 2013 at 6:28 am

  14. Delphia's avatar Delphia

    Hello! I just wanted to ask if you ever

    have any issues with hackers? My last blog (wordpress) was hacked and I

    ended up losing months of hard work due to no back up.

    Do you have any methods to prevent hackers?

    #125 – 25 January, 2013 at 3:26 am

  15. http://sulfate-freeshampoo.net/'s avatar http://sulfate-freeshampoo.net/

    May I simply just say what a relief to discover someone that truly knows what they're discussing on the internet. You actually realize how to bring a problem to light and make it important. A lot more people have to look at this and understand this side of the story. It's surprising you aren't more popular since you certainly possess the gift.

    #124 – 18 January, 2013 at 2:02 am

  16. nono hair removal compared to silk slkn sensepil's avatar nono hair removal compared to silk slkn sensepil

    You can certainly see your skills in the article you write.

    The arena hopes for even more passionate writers like

    you who aren't afraid to say how they believe. At all times follow your heart.

    #123 – 7 January, 2013 at 7:27 am

  17. Pravana Sulfate Free Shampoo's avatar Pravana Sulfate Free Shampoo

    Amazing things here. I am very satisfied to peer your

    post. Thanks so much and I'm having a look forward to contact you. Will you please drop me a mail?

    #122 – 6 September, 2012 at 1:28 am

  18. read more's avatar read more

    If you are going for best contents like me, only pay a quick visit this site all the time for

    the reason that it provides quality contents, thanks

    #121 – 3 September, 2012 at 7:47 am

  19. corey haim's avatar corey haim

    Hmm is anyone else encountering problems with the images on

    this blog loading? I'm trying to figure out if its a problem on my end or if it's the blog.

    Any responses would be greatly appreciated.

    #120 – 20 August, 2012 at 4:14 am

  20. Laverne's avatar Laverne

    When I originally commented I appear to have clicked

    the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment.

    There has to be a means you are able to remove me from that service?

    Thanks!

    #119 – 6 August, 2012 at 9:57 pm

Page 1 of 7 Next 20 »

Post a comment (Optional)
  • Allowed markup: <a> <i> <b> <em> <u> <s> <strong> <code> <pre> <p>
  • All other tags will be stripped, unless they are in a <pre> (use this for blocks of code)
  • External links will have the rel="nofollow" attribute applied