Zen Cart Logo
Forums / General Questions / How to Link to External Images for Products - Solved

How to Link to External Images for Products - Solved

Locked

Views: 1,183

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
16 Mar 2009, 6:22 AM
#1
stevenlee avatar

stevenlee

New Zenner

Join Date:
Jun 2008
Posts:
85
Plugin Contributions:
0

How to Link to External Images for Products - Solved

Hello There,

I had a post a while ago that I was trying to display images hosted on another server and I figured out how, but it was after 5am and need to get some sleep, but I'm back to explain.

You edit the tpl_modules_main_product_image file which is located in /includes/templates/template_default/templates (after editing the file it is good practice to put the edited file in your custom template folder)

The file stock looks like this (after the credits)

<?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"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, '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>

modified to grab pictures from an external source it looks like this:

<div id="productMainImage" class="centeredContent back">
<?php
  echo '<img src="http://content.com/images/'.$products_model.'.jpg">';
?>
<script language="javascript" type="text/javascript"><!--
document.write('<?php echo '<a href="http://content.com/images/'.$products_model.'.jpg" target="_blank">' . 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="http://content.com/images/'.$products_model.'.jpg" 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>

As you can see, the file name is dynamically filled in by the model number, which can be the part number or whatever, also I could have taken out more code, but it works so I left it in.
If you have any questions, please let me know.

thank you,
Steve

16 Mar 2009, 6:30 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How to Link to External Images for Products - Solved

stevenlee,

Only will work if the donor systems' DB is structured with ".$products_model"
in their DB table definitions

2 Apr 2009, 11:38 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: How to Link to External Images for Products - Solved

... and means that you have to already have all images properly sized, since you won't be able to use any of Zen Cart's built-in image-size-protection features.