Forums / General Questions / How do I use non-JPG images as my product image?

How do I use non-JPG images as my product image?

Views: 887

Results 1 to 10 of 10
26 May 2011, 6:39 AM
#1
bparker avatar

bparker

Zen Follower

Join Date:
Oct 2008
Location:
Rochester, NY
Posts:
232
Plugin Contributions:
0

How do I use non-JPG images as my product image?

Zen Cart allows you to have three versions of a product image: small, medium, and large. This is done by adding _LRG, for example, at the end of the file's name. I want to use both small and medium as JPGs, but the large I want to be a PDF or GIF. How do I do this?

Thanks,
BP

26 May 2011, 6:40 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: How do I use non-JPG images as my product image?

Out-of-the-box Zen Cart doesn't support alternate file extensions for the different sized images.
You might find some addons that replace the built-in functionality with other approaches, with varying measures of success ... which might suit your needs.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 May 2011, 6:43 AM
#3
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: How do I use non-JPG images as my product image?

I don't know that this can be done in the stock zencart

If all three sizes of image are using the same image, then imagehandler3 can do this for you, just upload your large image as a png or gif and then go to the image settings and set the image type for medium and small images to be jpgs and image handler will automatically create small and medium sized jpegs from the large png and serve them as and when required

Webzings Design
Semi retired from Web Design

26 May 2011, 7:03 AM
#4
bparker avatar

bparker

Zen Follower

Join Date:
Oct 2008
Location:
Rochester, NY
Posts:
232
Plugin Contributions:
0

Re: How do I use non-JPG images as my product image?

Wow! Thanks for the quick reply! :)

Actually, if I can just add a link to each product page, that should suffice. Is this possible? How can I do it?

And by add to each product page, I mean put a unique link to each image depending on the product.

Thanks,
BP

26 May 2011, 7:10 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: How do I use non-JPG images as my product image?

Your product descriptions are just HTML, so just add an <img> tag pointing to whatever unique image you think is needed outside the normal product image capabilities.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 May 2011, 8:22 AM
#6
bparker avatar

bparker

Zen Follower

Join Date:
Oct 2008
Location:
Rochester, NY
Posts:
232
Plugin Contributions:
0

Re: How do I use non-JPG images as my product image?

Good solution! Wow, it's late, and my brain is tired. :wacko: I should have thought of that one. :) Thanks!

27 May 2011, 7:48 AM
#7
bparker avatar

bparker

Zen Follower

Join Date:
Oct 2008
Location:
Rochester, NY
Posts:
232
Plugin Contributions:
0

Re: How do I use non-JPG images as my product image?

Actually... now that I think of it, that's not the most practical solution. Maybe I can modify the code myself. Do you know where the script is that dictates what to do when the product image is clicked? Maybe I can make the JavaScript open a PDF of the same name instead of the same image or one ending in _LRG.

Thanks,
BP

27 May 2011, 7:44 PM
#8
bparker avatar

bparker

Zen Follower

Join Date:
Oct 2008
Location:
Rochester, NY
Posts:
232
Plugin Contributions:
0

Re: How do I use non-JPG images as my product image?

Ok, I've found a workaround. I'm going to share a solution.

If you use name.jpg and name.pdf (using the same name for each file but a different extension), this should work.

Open this file:

/includes/templates/MY_CUSTOM_TEMPLATE_NAME/templates/tpl_modules_main_product_image.php

And change the source code to this:

<?php require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE)); ?> 
<div id="productMainImage" class="centeredContent back">
<script language="javascript" type="text/javascript">
<?php
$myTempName = str_replace('.jpg','',$products_image_medium);
$myTempName = $myTempName.".pdf";
?>
<!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . zen_href_link($myTempName, 'pID=' . $_GET['products_id']) . '\\\')">' . zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?>');
//--></script>
<noscript>
<?php
  echo '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '" target="_blank">' . zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>';
?>
</noscript>
</div>

There :) :clap:

27 May 2011, 8:08 PM
#9
bparker avatar

bparker

Zen Follower

Join Date:
Oct 2008
Location:
Rochester, NY
Posts:
232
Plugin Contributions:
0

Re: How do I use non-JPG images as my product image?

Better code:

<?php require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE)); ?> 
<div id="productMainImage" class="centeredContent back">
<script language="javascript" type="text/javascript">
<?php
$myTempName = str_replace('.jpg','',$products_image_medium);
$myTempName = $myTempName.".pdf";
?>
<!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . $myTempName . '\\\')">' . zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?>');
//--></script>
<noscript>
<?php
  echo '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '" target="_blank">' . zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>';
?>
</noscript>
</div>
27 May 2011, 9:59 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: How do I use non-JPG images as my product image?

bparker:

Open this file:

/includes/templates/template_default/templates/tpl_modules_main_product_image.php
Um ... no.

NEVER EDIT the template_default files directly.
If you need to edit one, then make a COPY of it, and locate it in your custom template folder, and edit it THERE.

Tutorials on creating custom templates are available by clicking on the Tutorials/FAQs link at the top of this page.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.