|
$ Directory = 'Gallery ';
$ Allowed_types = array ('jpg ', 'jpeg', 'GIF', 'PNG ');
$ File_parts = array ();
$ Ext = '';
$ Title = '';
$ I = 0;
$ Dir_handle = @ opendir ($ directory) or die ("there is an error with your image directory! ");
While ($ file = readdir ($ dir_handle ))
{
If ($ file = '.' | $ file = '..') continue;
$ File_parts = explode ('.', $ file );
$ Ext = strtolower (array_pop ($ file_parts ));
$ Title = implode ('.', $ file_parts );
$ Title = htmlspecialchars ($ title );
$ Nomargin = '';
If (in_array ($ ext, $ allowed_types ))
{
If ($ I + 1) % 4 = 0) $ nomargin = 'nomargin ';
Echo'
<Div class = "pic '. $ nomargin. '"style =" background: url ('. $ directory. '/'. $ file. ') no-repeat 50% 50%; ">
<A href = "'. $ directory. '/'. $ file. '"title = "'. $ title. '"target =" _ blank "> '. $ title. '</a>
</Div> ';
$ I ++;
}
}
Closedir ($ dir_handle ); |