Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

automatic check for link pictures in path

Quote Reply
automatic check for link pictures in path
hi,
this is not really a plugin but maybe helpful for
someone. we used this subroutine to save database
space and have a way to automatically add pictures
for each link in the database (product pictures for
our shop)
all you need is a path where you put your pictures .jpg or .gif and one image for no picture
saying something like: sorry no image yet.
We added this in a Module called Shop.pm but
you could insert it via the admin area in the globals either. then you have to call it:
<%Shop::get_picture('$ID')%>

sub get_picture {
my $path = "/path/where/you/put/your/images/";
my $url = "/path/for/img/src/";
my ($pic,$img,$pic2,$img2);
$pic = $path . $_[0].gif;
$img = "$_[0].gif";
$pic2 = $path . $_[0].jpg;
$img2 = "$_[0].jpg";
stat("$pic");
stat("$pic2");
if (-e $pic) {return qq~<img src="~ . $url . $img . qq~">\n~;}
elsif (-e $pic2) {return qq~<img src="~ . $url . $img2 . qq~">\n~;}
else {return "return qq~<img src="~ . $url . qq~noimage.gif">\n~;} #the name for your sorry image
}

hope someone can use this or has suggestions for
easier ways.

regards

niko
Subject Author Views Date
Thread automatic check for link pictures in path el noe 2538 Nov 21, 2001, 9:54 PM
Thread Re: [el noe] automatic check for link pictures in path
el noe 2330 Oct 11, 2002, 5:37 AM
Post Re: [el noe] automatic check for link pictures in path
Andy 2338 Oct 11, 2002, 5:43 AM