Gossamer Forum
Home : Products : Gossamer Links : Discussions :

display a photo with <%URL%> instead of the jump.cgi

Quote Reply
display a photo with <%URL%> instead of the jump.cgi
How to dislay a photo in static mode using the <%URL%> instead of the jump.cgi for the following:

<img src="my site..../cgi-bin/znews/jump.cgi?ID=<%ID%>&v=Photo" width="120" border="0"></a>

Please advise
Thanks
Antoine

Last edited by:

antoined: Feb 20, 2009, 7:04 AM
Quote Reply
Re: [antoined] display a photo with <%URL%> instead of the jump.cgi In reply to
Hi,

Assuming you have both file_save_url and file_save_path set in your FILE field, then this will work for you:

Code:
<%Plugins::ULTRAGlobals::Get_Image_URL($ID,'Photo','Links')%>

(obviously install the free ULTRAGlobals plugin first though , link in my signature)

Cheers

Andy (mod)
andy@ultranerds.co.uk
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!
Quote Reply
Re: [Andy] display a photo with <%URL%> instead of the jump.cgi In reply to
that you Andy for that, but I am on an old links sql 2.1.0! . Your plugin requires the Links SQL 3!
Quote Reply
Re: [antoined] display a photo with <%URL%> instead of the jump.cgi In reply to
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
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!
Quote Reply
Re: [Andy] display a photo with <%URL%> instead of the jump.cgi In reply to
I have different output on the same page links.html:

some Photos are coming out with <img src="/5/45-students-assembly.jpg" /> which could be ok .

But others are coming out with "t" after the .com and with full URL:

<img src="http://www.mysite.comt/znews/pages/images/default/3/323-north_tn.gif" />


Let me know please
thanks
Antoine
Quote Reply
Re: [antoined] display a photo with <%URL%> instead of the jump.cgi In reply to
Mmm sorry, been a while since I worked on LSQL 2.1 (I actually only started working on LSQL 2.1.1)

Any reason you're using such an old version? ;)

Cheers

Andy (mod)
andy@ultranerds.co.uk
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!
Quote Reply
Re: [Andy] display a photo with <%URL%> instead of the jump.cgi In reply to
Sorry Andy, I am working on Links SQL 2.2.1 !
Quote Reply
Re: [antoined] display a photo with <%URL%> instead of the jump.cgi In reply to
Ok, np.

Not a lot I can do without taking a look at how you have the field setup (to see if its setup so that it will work ok). If you want, PM me your admin login details (for LSQL admin), and I'll take a look for you.

Cheers

Andy (mod)
andy@ultranerds.co.uk
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!
Quote Reply
Re: [Andy] display a photo with <%URL%> instead of the jump.cgi In reply to
PM sent
Many Thanks
Antoine
Quote Reply
Re: [antoined] display a photo with <%URL%> instead of the jump.cgi In reply to
Hi,

Just took a quick look, and it seems the problem is with your File_URL values in lsql_Links_Files.

If you run this command in Database SQL Monitor, you will see what I mean:

Code:
SELECT * FROM lsql_Links_Files ORDER BY ID

Very few of the records even have a file URL.

The only thing I can think of, is a bug fix for "modifying". Having a quick look, I think this is the bug fix you will need:

http://www.gossamer-threads.com/...QL%3A%3AFile#p253464

The only downside, is that it means all the existing records you have, will not have the File_URL set. To fix this, you can run this command via SQL Monitor:

Code:
UPDATE lsql_Links_Files SET File_URL = 'http://www.zgharta.comt/znews/pages/images/default' WHERE File_URL IS NULL;

Untested, but hopefully that should work for you :)

Be sure to backup your DB before running this query though, in case it doesn't do what you expect!

Cheers

Andy (mod)
andy@ultranerds.co.uk
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!