You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
This little hack will do away with having to keep images to the sizes listed in admin image sizes. (you still want to keep them consistent)
You need the Image::Magick library available
category images
in ste_cat.pl at the top
put use Image::Magick;
find ste_cat_show_image
after:
if (($image_name ne "") && (-e "$server_media_path/images/category/$image_name")) {
put:
$image = Image::Magick->new;
$image->Read("$server_media_path/images/category/$image_name");
($width, $height) = $image->Get('width', 'height');
then replace the next line:
print "<IMG SRC="$images_path/category/$image_name" WIDTH="$store_cat_image_width" BORDER="0">";
with:
print "<IMG SRC="$images_path/product_detail/$image_name" width="$width" height="$height" BORDER="0">";
this technique will also work with product images in ste_prod.pl
ste_prod_show_image and ste_prod_show_image_detail you just have to make sure the paths are correct
now your images will have the height and width attributes added.
There may be a better way to get the actual image size...
Offline
Wayne I am trying to do this but I am getting this error:
Script Execution Error
The following error was just encountered:
Can't locate Image/Magick.pm in @INC (@INC contains: /home/clickca/public_html/cgi-bin/modules /usr/lib/perl5/5.6.1/i686-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i686-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl . /home/clickca/public_html/cgi-bin/dbi) at /home/clickca/public_html/cgi-bin/library/modules/ste_cat.pl line 5. BEGIN failed--compilation aborted at /home/clickca/public_html/cgi-bin/library/modules/ste_cat.pl line 5.
Thanks,
Chris
wwwsite_name_deleted.com
wwwequivity.com - e-Commerce Website hosting starting at $5.95/month
Offline
I suspect your host does not have image::magick installed.
Somewhere around here was a link to a helper script that will list the modules installed, paths etc.
You may be able to install in your web space.
Offline
It is installed on the server, but I do not think I am calling the module, or pointing to it corectly
Thanks,
Chris
wwwsite_name_deleted.com
wwwequivity.com - e-Commerce Website hosting starting at $5.95/month
Offline
It must installed somewhere other than in the directores in the @INC path.
If you know where it is you can add to that path using
use lib '/path/to/wherever/it/is';
use Image::Magick;
Wayne,
I tried this and I did not get any error but none of the category pictures showed up, it was almost like it did not know what size to make them so it made them 0. Any ideas?
Thanks,
Chris
http://www.site_name_deleted.com
http://www.equivity.com - e-Commerce Website hosting starting at $5.95/month
Offline
<font size="1" color="#FF0000">LAST EDITED ON 08-01-03 AT 07:52 AM (EST) Wrong element was referenced</font><p>here is the whole routine for category image display
after my $image_name = shift; you could add print "$server_media_path/images/category/$image_name"; for debugging to see if it is looking in the right place.
#######################################################################
# Ste Cat Show Image #
#######################################################################
#wk
sub ste_cat_show_image {
&initialize_sub_add('ste_cat_show_image');
#########
######### This routine displays category images when available.
#########
my $image_name = shift;
if (-e "$server_media_path/images/category/$image_name") {
$image = Image::Magick->new;
$image->Read("$server_media_path/images/category/$image_name");
($width, $height) = $image->Get('width', 'height');
print "<IMG SRC="$images_path/category/$image_name" width="$width" height="$height" border="0">";
} else {
print "<IMG SRC="$images_path/category/none.gif" width="$store_cat_image_width" border="0">";
} ######### End of if statement.
&initialize_sub_remove('ste_cat_show_image');
} ######### End of subroutine.
ste_cat.txt
(CGIGET TYPE="SUB" VALUE="ste_exec_storehead")
(CGIGET TYPE="SUB" VALUE="ste_cat_desc")
<div align="center"><!-- #wk added to show image when category is displayed --><!-- #wk must point to correct directory category_imgsm or category_imglg-->
(CGIGET TYPE="SUB" VALUE="ste_cat_show_image" PARAMS="(CGIVAR)category_imgsm(/CGIVAR)")</div><br>
(CGIGET TYPE="SUB" VALUE="ste_cat_disp")
(CGIGET TYPE="SUB" VALUE="ste_prod_disp")
(CGIGET TYPE="SUB" VALUE="ste_cart_shop")
<!-- ste_cat.txt -->
Offline
Wayne,
How can I set this up to use across all images in CCP, or at the very least all product and category images?
Offline
Wayne
I think, but not, if I got it working correctly. But is this supposed to resize any picture based on the values we set in the "Manager Image Settings" in CCP admin. If so, then mine still is not working, becuase I put a very large image in for a category and it is showing the full image, it is not reduced at all.
I really would like to get this thing working.
Offline
No, this displays the image at it's current size. It puts the actual image dimensions in the img tag overriding the global settings in ccp.
to use this for other images, you need to edit the image display routines for products, small product image and in ccp 5.1 the extra large product image.
The way it is done is similar.
image::magick is a very powerful module capable of image manipulation and creation I suggest you read
Offline
try using this for ste_cat.txt
Make a backup
(CGIGET TYPE="SUB" VALUE="ste_exec_storehead")
(CGIGET TYPE="SUB" VALUE="ste_cat_desc")
<div align="center"><!-- #wk added to show image when category is displayed --><!-- #wk must point to correct directory category_imgsm or category_imglg-->
(CGIGET TYPE="SUB" VALUE="ste_cat_show_image" PARAMS="(CGIVAR)category_imgsm(/CGIVAR)")</div><br>
(CGIGET TYPE="SUB" VALUE="ste_cat_disp")
(CGIGET TYPE="SUB" VALUE="ste_prod_disp")
(CGIGET TYPE="SUB" VALUE="ste_cart_shop")
<!-- ste_cat.txt -->
and
both use this hack
Offline
I visited both these sites and was unable to locate and images with popup windows, I probably just didn't know which products are using popups.
and
can you let know which pages and which ites so I may check them out?
Offline
this is all great BUT
who knows how to install Image::Magick on a web server that i am renting space from. i have it installed perfectly on my computer with apache2 for windows and the release of activestateperl.....but, who knows how to install the module on a web server if you dont have root access?????
Offline
You might not necessarily need root privileges...
From the ImageMagick download page:
By default, make install
will install the package's files in `/usr/local/bin', `/usr/local/lib', etc.. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. This is valuable in case you don't have privileges to install under the default paths or if you want to install in the system directories instead.
Good Luck!
Offline
Also, by slamming a module into a user directory and using the 'use lib' pragma in the Perl code, you may be able to get around the root requirement. Ie:
usr lib "/path/to/user/dir";
use ImageMagick;
(Assuming ImageMagick is in /path/to/user/dir)
Offline