To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.publish.htmlOpen lugnet.publish.html in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Publishing / HTML / 31
30  |  32
Subject: 
Thumbnail menu CGI script
Newsgroups: 
lugnet.off-topic.geek, lugnet.publish.html
Date: 
Thu, 18 Jan 2001 17:58:50 GMT
Viewed: 
49 times
  
I've written a perl subroutine (thanks, Paul Hartzog) which finds all the files
in a directory and returns some HTML code for thumbnails with links to those
images.  Is there a way I can modify this code so it can work with a URL
instead of a directory?  For example, so I can make thumbnail links to all the
images in my Brickshelf gallery...

Here is the subroutine ($imgdir is the directory to look in for images.)
-----------------------------------
sub thumbnailmenu {
   my $thdr = $imgdir . "/thumb";
   my $htmlcode = "";

   opendir (INDIR,$imgdir);
   chdir $imgdir;

   foreach (sort readdir (INDIR) ) {
      my $file = $_;
      my $filesize = -s $file;

      if (-f $file){
         $htmlcode = $htmlcode . "<a href=\"$imgdir/" . $file . "\">";
         $htmlcode = $htmlcode . "<img src=\"$thdr/" . $file .
             "_thumb.jpg\" alt=\"[" . $filesize . " bytes]\">";
         $htmlcode = $htmlcode . "</a>\n";
      }
   }
   closedir (INDIR);

   return $htmlcode;
}
-----------------------------------
Thanks in advance!
--Bram


Bram Lambrecht
bram@cwru.edu
http://home.cwru.edu/~bxl34/



Message has 1 Reply:
  Re: Thumbnail menu CGI script
 
(...) no simple way - since the script assumes you have local access to the directory... and since there is no real way of you knowing what files are in a directory on the webserver, unless it allows you to list them. the only thing you can do is (...) (24 years ago, 18-Jan-01, to lugnet.off-topic.geek)

11 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR