Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Images on templates ?

Quote Reply
Images on templates ?
here i'm again,
i would to know what is the source of my images in templates is : http://domain.com/img/image.gif
or <%build_site_url%>/img/image.gif
or auther thing .
merci

Quote Reply
Re: Images on templates ? In reply to
You can use the full URL to an image; if the images are on your server, just reference the appropriate directory like
Code:
/img/image.gif
or just use
Code:
<%build_site_url%>/img/image.gif
Thomas
http://www.japanreference.com
Quote Reply
Re: Images on templates ? In reply to
I would recommend creating a GLOBAL tag for your image directory.

Like the following:

1) Create the following variable in your links.cfg file:

Code:

$build_img_dir = "$build_root_url/imgs";


2) Then add the following in the %globals hash in the site_html_templates.pl file:

Code:

img_dir => $build_img_dir


REMEMBER to add a comma at the end of the line before the LAST TAG DEFINITION in the %globals hash, like the following:

Code:

site_title => $build_site_title[/b],[/b]
img_dir => $build_img_dir


3) Then add the following tags and codes in your template files:

Code:

<img src="<%img_dir%>/something.gif" width="" height="" alt="" border="">



Good luck!

And...this is a recording...

Regards,

Eliot Lee
Quote Reply
Re: Images on templates ? In reply to
Hello

Thanks a lot Eliot for the tip and your help in all forums Laugh

Ciao

Quote Reply
Re: Images on templates ? In reply to
By using the build_root_url, that would take longer to load the images since you're calling from the server for each image. Would it be possible to use build_root_path instead? Thx. :>

Jon | netchitecture@home.com
http://www.netchitecture.f2s.com/
Quote Reply
Re: Images on templates ? In reply to
Uh NO...The build_root_path is the ABSOLUTE path and thus the images would never show up.

If you want to use a VIRTUAL PATH, then you could use something like:

Code:

$build_image_path = "/virtual/path/to/images";


Then create a global variable in the %globals hash in the site_html_templates.pl file:

Code:

build_image_path => $build_image_path


Then in the template files, use:

Code:

<img src="<%build_image_path%>/image.gif" alt="" width="" height="" border="">


OF COURSE, the easier thing to do is create additional IMAGE variables in the links.cfg file, like the following:

Code:

$new_image = 'img src="$build_image_path/new.gif" alt="new" width="" height="" border=""';


Then create global variables in the %globals section in the site_html_templates.pl file:

Code:

new_img => $new_img


Then simply use:

Code:

<%new_img%>


GOT it? Tongue

Regards,

Eliot Lee
Quote Reply
Re: Images on templates ? In reply to
Okay, I understand the second method but what is a "virtual path"? Thx again! :>

Jon | netchitecture@home.com
http://www.netchitecture.f2s.com/
Quote Reply
Re: Images on templates ? In reply to
Uh...like /images/...VIRTUAL PATH!

Regards,

Eliot Lee
Quote Reply
Re: Images on templates ? In reply to
Okay, I get it all now and it works. Thanks! :>

Jon | netchitecture@home.com
http://www.netchitecture.f2s.com/
Quote Reply
Re: Images on templates ? In reply to
Good, and you're welcome.

Regards,

Eliot Lee