This code modifies the “Single File PHP Gallery” version 4.1.1 (by Kenny Svalgaard). I use his excellent gallery script, and I love it. However, I ran into one minor issue. In the cases in which an image would have an attached directory of files for that image, the gallery would display this directory of files in addition to displaying the image. And the directory of files would use a thumbnail of the image as the cover, so, in effect, the gallery would appear to have 2 thumbnails of the same image.
These directories of files that are attached to most images are named beginning with the image name followed by “.files”.
For example, an image named “picture_01.jpg
” would have an accompanying directory named “picture_01.jpg.files
“.
So I needed to exclude from the gallery all directories ending with “.jpg.files
“. But there is no built-in function to do this in the Single File PHP Gallery script. The script does have built-in functions to exclude by filename or by file extension. However “.jpg.files
” does not qualify as a file extension, because this is part of a directory name, not a “file” name.
The script also has a built-in function to exclude by directory name, but not by part of directory name (the ending), which is what I need. To repeat, I needed to exclude from the gallery all directories ending with “.jpg.files
“.
This is very simple to do by modifying the script. This is how it’s done:
Step 1 – Open
If you have the Single File PHP Gallery script, version 4.1.1., open up its index.php
.
Step 2 – Find
Find the following line of code. It should be on line 313.
if (($var != ".") and ($var != "..") and !in_array(strtolower($var), $dir_exclude))
Step 3 – Replace
Now that you have found the line of code in the step above, replace it with the following line of code:
if (($var != ".") and ($var != "..") and !in_array(strtolower($var), $dir_exclude) and (strpos($var, ".jpg.files") === false) )//isa added last condition
That’s it. Now those pesky “.jpg.files
” folders will be hidden from your gallery.
Questions and Comments are Welcome