[ic] Multiple Images Support - Workable Solution

Paul Rogers paul at btsnet.co.uk
Sat Mar 5 04:29:51 EST 2005




Hi all,

After searching the mailing list for a solution for handling multiple images
I decided to put
together something that's easy to implement and doesn't require modifying
the existing admin UI.

The solution I've come up with allows just that and requires only a slight
modification to flypage.html.
This has only been tested on Interchange 5.20 so may not work on earlier
versions.

Add the following perl code to the top of your page content on flypage:

[perl no_return=1]
$filename = [item-field image];
$Session->{mv_perl_result} = substr($filename, 0, -5);
[/perl]

Then add the following thumbnail and image links to your content where you
want it:

[if type=file term="/full system path to/images/thumb/[data session
mv_perl_result]_thumb2.gif"]
  <a href="/items/[data session mv_perl_result]_2.gif">
   <img border="0" src="thumb/[data session mv_perl_result]_thumb2.gif"
width=60 height=60 alt="Click to view"></a>
[/if]

[if type=file term="/full system path to/images/thumb/[data session
mv_perl_result]_thumb3.gif"]
  <a href="/items/[data session mv_perl_result]_3.gif">
   <img border="0" src="thumb/[data session mv_perl_result]_thumb3.gif"
width=60 height=60 alt="Click to view"></a>
[/if]



Here's how it works:

Name all your normal size images in the format imagename_1.gif,
imagename_2.gif etc and upload normally using
the admin UI.

The Perl code then takes image filename from [item-field image] and then
removes the last 5 characters and returns the image name
only which can then be used in flypage as above. The IF checks for the
presence of image_thumb2.gif, and if it's there,
loads the thumbnail with a link to larger image.   A simple Javascript
ImageSwap program can be used to allow thumbnails
clicks to replace the main image with corresponding image.

Notes:

1. All images must have the same filename, with the file number appended
onto end as per 2.
2. Normal sized images should be named as _1.gif, _2.gif  etc, and thumbnail
images should be named as _thumb1.gif, thumb2.gif
2. First images should be uploaded normally via admin UI Add new item page,
other images can be uploaded using FTP or admin UI.
3. Since no further db queries for images are needed after the first image
query, this solution should have some performance benefits
     on busy sites.

A more complete copy of this mod with Javascript can be found on my
Interchange support area at:
http://www.btsonline.co.uk/articles.php?a=read&aid=44

Hope this is useful to someone!

Any comments/suggestions for improvement welcomed.

amorphix

~~~~~~~~~~~~~~~~~
www.amorphix.net












--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.5.7 - Release Date: 01/03/05

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.6.2 - Release Date: 04/03/05



More information about the interchange-users mailing list