Hi,
You should be able to do it as a global:
Get_Image_URL
Code:
sub {
my ($ID,$field,$table) = @_;
$table ||= 'Links';
# make sure a fieldname and ID are provided...
if (!$ID || !$field) { return "You need to define the ID and fieldname."; }
# get the actual path to where the file is/will be saved...
my $schema = $DB->table($table)->cols;
my $path = $schema->{$field}->{'file_save_url'};
$path =~ s,/$,,; # get rid of trailing / at end of $path
my $image_details = $DB->table($table."_Files")->select( { ForeignColName => $field, ForeignColKey => $ID } )->fetchrow_hashref;
my $id = $image_details->{ID};
my $filename = $image_details->{File_Name};
my $file_url = $image_details->{File_URL}; # this is only the URL/folder
my @cut = split //, $id;
my $folderid = $cut[$#cut];
my $url = "$file_url/$folderid/$id-$filename";
$url =~ s|([^\/]+)$|GT::CGI->escape( $1 )|e;
return $url;
}
Then call with:
Code:
<%if Photo%>
<img src="<%Get_Image_URL($ID,"Photo")%>" />
<%endif%>
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work! Want to give me something back for my help? Please see my
Amazon Wish List GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500) Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin |
Pre-Made Template Sets |
FREE GLinks Plugins! Compare our different Plugin packages *new* Free CSS Templates