I went with a different method instead of a plugin and it works much better for me..
Template Global called: imageurl
my $field = shift;
my $tags = GT::Template->tags;
my $id = $tags->{ID};
if ($tags->{$field})
{
my $links_db = $DB->table('Links');
my $fh = $links_db->file_info( "$field", $id );
return "" unless($fh);
my $location = $fh->File_RelativePath;
my $logow = 75;
my $extra_atts="oriw=$tags->{LogoWidth}";
if($field eq "Logo" && $tags->{LogoWidth} ne "$logow"){
eval{
use Image::Magick;
};
$@ and return $@;
my $i= new Image::Magick();
my $if = $CFG->{build_root_path} . "/upload$location";
my $error = $i->Read($if);
return "Could not read $if file. Reason:" . $error if $error;
my $w = $i->Get('width');
$extra_atts .= ";width =$w";
if($w ne "$logow"){
my $h = $i->Get('height');
my $logoh = int($h*($logow/$w));
$error = $i->Resize(geometry => "${logow}x$logoh", width => $logow, height => $logoh);
return "Could not read $if file. Reason:" . $error if $error;
$extra_atts .= ";height=$h";
my $rs = $i->Write($if);
}
$links_db->update({LogoWidth => $logow},{ID => $id}) if($tags->{LogoWidth} ne "$logow");
}
return qq~$CFG->{build_root_url}/upload_images$location~;
}
else
{
return "";
}
}
Links Table Editor added:
Column Name: Upload_Image
Column Size: 255
Form Type: File
Form Size: 20
File Save Location: /home/httdocs/upload_images
File Save URL: http://yourdomain.com/upload_images
File Save Method: Simple
Form Regex: ^|.*\.(?i:gif|jpg|png)$
=======================================
I made one for the image and one for the thumbnail. simplified my life when on the road.
============================
It does require you have Image Magick on your server. If you’re not sure if you have it call you’re hosting provider and ask. If they don’t have it on there it takes seconds to add it.
Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Template Global called: imageurl
Code:
sub { my $field = shift;
my $tags = GT::Template->tags;
my $id = $tags->{ID};
if ($tags->{$field})
{
my $links_db = $DB->table('Links');
my $fh = $links_db->file_info( "$field", $id );
return "" unless($fh);
my $location = $fh->File_RelativePath;
my $logow = 75;
my $extra_atts="oriw=$tags->{LogoWidth}";
if($field eq "Logo" && $tags->{LogoWidth} ne "$logow"){
eval{
use Image::Magick;
};
$@ and return $@;
my $i= new Image::Magick();
my $if = $CFG->{build_root_path} . "/upload$location";
my $error = $i->Read($if);
return "Could not read $if file. Reason:" . $error if $error;
my $w = $i->Get('width');
$extra_atts .= ";width =$w";
if($w ne "$logow"){
my $h = $i->Get('height');
my $logoh = int($h*($logow/$w));
$error = $i->Resize(geometry => "${logow}x$logoh", width => $logow, height => $logoh);
return "Could not read $if file. Reason:" . $error if $error;
$extra_atts .= ";height=$h";
my $rs = $i->Write($if);
}
$links_db->update({LogoWidth => $logow},{ID => $id}) if($tags->{LogoWidth} ne "$logow");
}
return qq~$CFG->{build_root_url}/upload_images$location~;
}
else
{
return "";
}
}
Links Table Editor added:
Column Name: Upload_Image
Column Size: 255
Form Type: File
Form Size: 20
File Save Location: /home/httdocs/upload_images
File Save URL: http://yourdomain.com/upload_images
File Save Method: Simple
Form Regex: ^|.*\.(?i:gif|jpg|png)$
=======================================
I made one for the image and one for the thumbnail. simplified my life when on the road.
============================
It does require you have Image Magick on your server. If you’re not sure if you have it call you’re hosting provider and ask. If they don’t have it on there it takes seconds to add it.
Sandra Roussel
Chonsa Group Design - Fresh Start Housing