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
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:

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";
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.


Quote Reply
Re: [el noe] automatic check for link pictures in path In reply to
seem like all is in vain. the i just learned that probably the easiest way is to define a .htaccess file with e.g. the following parameters:

ErrorDocument 300 http://yourdomain/images/noimage.jpg
ErrorDocument 400 http://yourdomain/images/noimage.jpg
ErrorDocument 401 http://yourdomain/images/noimage.jpg
ErrorDocument 403 http://yourdomain/images/noimage.jpg
ErrorDocument 404 http://yourdomain/images/noimage.jpg
ErrorDocument 500 http://yourdomain/images/noimage.jpg

you can set the image path e.g. http://yourdomain/images/<%ID%>.jpg and if there is no image it will simply display noimage.jpg. Now I can use an image for any link just copy it to the path and it is not even neccessary to update the database or rebuild the pages.

Hope that helps somebody.


Quote Reply
Re: [el noe] automatic check for link pictures in path In reply to
If using this method, make sure you place it in the 'images' folder, otherwise if someone types http://www.domain.com/etet.html, they will just get the image Wink

Andy (mod)
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!