- How to order images and galleries?
- How to disable creation of resized images?
- How to set folder title image without displaying the image inside?
- How to configure DAlbum to use ImageMagick on Microsoft IIS?
- How to use NetPBM for image resizing?
- How to prevent direct image linking (hot linking)
How to order images and galleries?
Albums and images are sorted alphabetically by their filenames. For example,
images "first.jpg", "Second.jpg", "Third.jpg" and "Fourth.jpg" will be sorted
To change the order of images, rename them as 001-first.jpg, 002-Second.jpg,
003-Third.jpg and 004-Fourth.jpg correspondingly. There are many
utilities available which can simplify the renaming process - check
To hide the leading digits from your users without
manually editing every image caption in .albumdef.ini, uncomment and modify filename2title
function in your custom.php file as follows:
return ereg_replace( "^[0-9]+-", "", getfname($filename) );
This way your album users will see your images as "first", "Second", "Third"
and "Fourth" and in appropriate order.
You can also define your own sorting method by overriding CAlbum::Sort method
in derived class.
This example adds DescendingOrder custom field to albums. When it is set to "1"
in album properties, album contents will be sorted in descending order:
| ||class CExAlbumSortOrder extends CAlbum
// Get list of custom field names
function cmpAlbDesc($a, $b)
return -strcasecmp($a->m_sBaseFilename, $b->m_sBaseFilename);
return new CExAlbumSortOrder();
How to disable creation of resized images?
DAlbum does not create a resized image if the original image is smaller
than resized image size. Edit your config.php file and set
How to configure DAlbum to use ImageMagick on Microsoft IIS
$g_sResizeMethod="IM"; in config.php
- Edit $g_sConvertPath variable in config.php and set it to location where ImageMagick is installed. For example
Remember to replace all backslashes with forward slashes.
- You need to give IIS user account access rights to your C:\WINNT\SYSTEM32\Cmd.exe. The best way to do it is go to your IIS Admin, select reindex.php and set it to run as another user (not IUSR_xxx). More secure solution would be to disable anonymous access to reindex.php completely and set authentication on. Then you will be asked for username and password for Windows account every time you reindex the photo album.
- In order to run DAlbum test you will need to configure test.php account the same way as reindex.php in step 3.
- Ensure that temp directory is writeable by the same account.
How to set folder title image without displaying the image inside?
Create a file named:
inside your folder. This file should be smaller
or equal to your configured thumbnail size (default 128x128 pixels).
How to use NetPBM for image resizing?
If your host has NetPBM graphics software package
installed, you can use it to create thumbnails and resized images:
- Download and extract rsnetpbm.pl from rsnetpbm.zip
into DAlbum root directory. You may need to edit this file and
set directory where NetBMP package is installed.
CHMOD rsnetpbm.pl to be not executable (ex. 444).
- Edit your config.php file as follows:
| ||// Force command-line image resizing</span>
// Change it to location of your Perl interpreter if necessary</span>
$g_sThumbnailImArg="$g_sConvertPath ./rsnetpbm.pl #src# #target# ".
"$g_sThumbnailQuality $g_sThumbnailXSize $g_sThumbnailYSize";
$g_sResizedImArg ="$g_sConvertPath ./rsnetpbm.pl #src# #target# ".
"$g_sResizedQuality $g_sResizedXSize $g_sResizedYSize";|
Using a similar approach any command-line image resizing toolkit can be used with DAlbum.
How to prevent direct image linking (hot linking)
As your public images can be accessed by using a URL (ex.
your site may become subject to direct linking. This happens when somebody posts
URL of your image on another site or forum and hundreds of people suck your bandwidth
without even visiting your site.
To disable direct linking to your images, edit your config.php and ensure that the following
variables are set as follows:
This way DAlbum code is called every time an image is downloaded.
Then add the following code snippet to custom.php:
if (!isset($_COOKIE['DAlbum_Connection']) ||
// Check referrer. If referrer is our domain -
// allow access even if cookie is not set
if (isset($_SERVER['HTTP_HOST']) &&
hdr("404 Not found");
// Set cookie for one hour.
This code forces all DAlbum pages except photo.php to set a one-hour cookie on every visit.
If there is a direct link to photo.php, the cookie will not be set and "404 Page not found"
error returned to client. Page referer check is also performed to enable users with disabled cookies to
browse your site.