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

Re: [Evoir] Attachment Plugin

Quote Reply
Re: [Evoir] Attachment Plugin In reply to
I went with a different method instead of a plugin and it works much better for me..


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
Subject Author Views Date
Thread Attachment Plugin yogi 17129 Oct 10, 2002, 1:37 AM
Thread Re: [yogi] Attachment Plugin
ryel01 16534 Oct 14, 2002, 1:07 AM
Thread Re: [ryel01] Attachment Plugin
yogi 16467 Oct 14, 2002, 1:10 AM
Thread Re: [yogi] Attachment Plugin
AuctionGuy 16441 Oct 18, 2002, 9:18 PM
Thread Re: [AuctionGuy] Attachment Plugin
yogi 16457 Oct 20, 2002, 1:56 AM
Thread Re: [yogi] Attachment Plugin
AuctionGuy 16371 Oct 20, 2002, 11:25 AM
Post Re: [AuctionGuy] Attachment Plugin
yogi 16249 Oct 20, 2002, 11:36 PM
Post Re: [AuctionGuy] Attachment Plugin
yogi 16151 Oct 30, 2002, 2:32 AM
Thread Re: [AuctionGuy] Attachment Plugin
gatman 15835 Jan 31, 2003, 6:03 AM
Thread Re: [gatman] Attachment Plugin
estjohn 15900 Jan 31, 2003, 8:37 PM
Post Re: [estjohn] Attachment Plugin
estjohn 15856 Feb 2, 2003, 11:47 PM
Thread Re: [gatman] Attachment Plugin
yogi 15898 Feb 3, 2003, 1:01 AM
Thread Re: [yogi] Attachment Plugin
gatman 15744 Feb 3, 2003, 8:04 AM
Thread Re: [gatman] Attachment Plugin
yogi 15863 Feb 3, 2003, 8:34 AM
Thread Re: [yogi] Attachment Plugin
Evoir 15775 Feb 14, 2003, 12:52 PM
Thread Re: [Evoir] Attachment Plugin
yogi 15761 Feb 14, 2003, 12:56 PM
Thread Re: [yogi] Attachment Plugin
Evoir 11333 Feb 14, 2003, 1:03 PM
Thread Re: [Evoir] Attachment Plugin
yogi 11454 Feb 14, 2003, 1:05 PM
Post Re: [yogi] Attachment Plugin
Evoir 11264 Feb 18, 2003, 1:44 PM
Post Re: [yogi] Attachment Plugin
Evoir 11303 Feb 18, 2003, 1:52 PM
Post Re: [yogi] Attachment Plugin
Evoir 11268 Feb 18, 2003, 2:14 PM
Thread Re: [yogi] Attachment Plugin
Evoir 11306 Feb 26, 2003, 11:32 PM
Thread Re: [Evoir] Attachment Plugin
yogi 11384 Feb 27, 2003, 12:44 AM
Thread Re: [yogi] Attachment Plugin
Evoir 11258 Feb 27, 2003, 9:55 AM
Thread Re: [Evoir] Attachment Plugin
yogi 11327 Feb 27, 2003, 10:21 AM
Post Re: [yogi] Attachment Plugin
Evoir 11230 Feb 27, 2003, 10:55 AM
Post Re: [yogi] Attachment Plugin
Evoir 11152 Apr 16, 2003, 4:51 PM
Post Re: [yogi] Attachment Plugin
Evoir 11110 Apr 24, 2003, 12:56 AM
Thread Re: [ryel01] Attachment Plugin
yogi 16328 Oct 30, 2002, 6:58 AM
Thread Re: [yogi] Attachment Plugin
Mark2 16269 Oct 30, 2002, 9:32 AM
Thread Re: [Mark2] Attachment Plugin
yogi 16230 Oct 30, 2002, 12:12 PM
Thread Re: [yogi] Attachment Plugin
yogi 16182 Nov 6, 2002, 5:55 AM
Thread Re: [yogi] Attachment Plugin
BLOOD 16010 Jan 21, 2003, 9:44 AM
Thread Re: [BLOOD] Attachment Plugin
yogi 16084 Jan 21, 2003, 2:19 PM
Thread Re: [yogi] Attachment Plugin
SSmeredith 15934 Jan 25, 2003, 10:25 AM
Thread Re: [SSmeredith] Attachment Plugin
yogi 15999 Jan 25, 2003, 1:29 PM
Post Re: [yogi] Attachment Plugin
SSmeredith 15919 Jan 27, 2003, 4:50 PM
Thread Re: [yogi] Attachment Plugin
sangiro 11219 Apr 3, 2003, 10:18 PM
Thread Re: [sangiro] Attachment Plugin
yogi 11231 Apr 3, 2003, 11:43 PM
Post Re: [yogi] Attachment Plugin
sangiro 11192 Apr 4, 2003, 5:56 PM
Thread Re: [yogi] Attachment Plugin
Franco 10853 Aug 23, 2003, 9:18 AM
Thread Re: [Franco] Attachment Plugin
yogi 10926 Sep 7, 2003, 12:14 AM
Thread Re: [yogi] Attachment Plugin
romanslon 10993 Sep 15, 2003, 7:21 AM
Thread Re: [romanslon] Attachment Plugin
SandraR 10803 Jul 27, 2004, 5:43 PM
Thread Re: [SandraR] Attachment Plugin
SandraR 10767 Jul 29, 2004, 12:54 PM
Post Re: [SandraR] Attachment Plugin
pugdog 7750 Aug 2, 2004, 9:00 AM
Thread Re: [sangiro] Attachment Plugin
Clint 11025 May 4, 2003, 11:57 PM
Thread Re: [Clint] Attachment Plugin
SSmeredith 11045 Jun 12, 2003, 12:40 PM
Post Re: [SSmeredith] Attachment Plugin
Clint 10981 Jun 13, 2003, 1:59 AM
Post Re: [yogi] Attachment Plugin
hannahmackenzie 11175 Apr 15, 2003, 9:31 AM
Post Re: [yogi] Attachment Plugin
Clint 11084 Apr 25, 2003, 9:48 PM
Thread Re: [yogi] Attachment Plugin
mick31 7803 Jan 10, 2005, 12:45 AM
Thread Re: [mick31] Attachment Plugin
SandraR 7669 Jun 8, 2005, 7:19 PM
Thread Re: [SandraR] Attachment Plugin
SandraR 7555 Feb 14, 2006, 2:19 PM
Thread Re: [SandraR] Attachment Plugin
pugdog 7544 Feb 17, 2006, 12:42 AM
Post Re: [pugdog] Attachment Plugin
mick31 7487 Feb 17, 2006, 2:47 AM
Thread Re: [pugdog] Attachment Plugin
SandraR 7584 Feb 17, 2006, 12:42 PM
Thread Re: [SandraR] Attachment Plugin
pugdog 7499 Feb 19, 2006, 8:33 PM
Post Re: [pugdog] Attachment Plugin
SandraR 7457 Feb 20, 2006, 8:13 AM
Thread Re: [SandraR] Attachment Plugin
Evoir 7368 Jul 6, 2006, 5:24 PM
Thread Re: [Evoir] Attachment Plugin
SandraR 7380 Jul 6, 2006, 6:14 PM
Thread Re: [SandraR] Attachment Plugin
Evoir 7371 Jul 6, 2006, 8:23 PM
Thread Re: [Evoir] Attachment Plugin
SandraR 7387 Jul 6, 2006, 8:33 PM
Post Re: [SandraR] Attachment Plugin
SandraR 7283 Jul 6, 2006, 8:46 PM
Post Re: [yogi] Attachment Plugin
MJ_ 7211 Apr 26, 2007, 2:37 AM