External images for products

01.06.2015 17:23
#1
algaja
Joomshopping forum user no avatar
Name: Janar
25.05.2015
Posts: 1
Quote
External images for products

I have added support to products page to display external images (from other source, then localhost).
For that I have made some minor chnages in components/com_jshopping/lib/functions.php file, function getPatchProductImage().

Befour:
function getPatchProductImage($name, $prefix = '', $patchtype = 0){
$jshopConfig = JSFactory::getConfig();
if ($name==''){
return '';
}
if ($prefix!=''){

$name = $prefix."_".$name;
}

if ($patchtype==1){
$name = $jshopConfig->image_product_live_path."/".$name;
}
if ($patchtype==2){
$name = $jshopConfig->image_product_path."/".$name;
}

return $name;
}


After:
function getPatchProductImage($name, $prefix = '', $patchtype = 0){
$jshopConfig = JSFactory::getConfig();
if ($name==''){
return '';
}
if ($prefix!=''){
$name = (strpos($name, 'http:') === 0) ? $name : $prefix."_".$name;

}

if ($patchtype==1){
$name = (strpos($name, 'http:') === 0) ? $name : $jshopConfig->image_product_live_path."/".$name;
}
if ($patchtype==2){
$name = (strpos($name, 'http:') === 0) ? $name : $jshopConfig->image_product_path."/".$name;
}

return $name;
}


And in template files (where are displaied product images) I have made also some minor changes:
Befour:
<img class="jshop_img" src="<?php print $product->image?>" alt="<?php print htmlspecialchars($product->name);?>" title="<?php print htmlspecialchars($product->name);?>" />


After:
<img class="jshop_img" src="<?php echo getPatchProductImage($product->product_name_image, 'thumb', 1); ?>" alt="<?php echo htmlspecialchars($product->name);?>" title="<?php print htmlspecialchars($product->name);?>" />


For lightbox link
Befour:
<a class="lightbox" id="main_image_full_<?php print $image->image_id?>" href="<?php print $this->image_product_path?>/<?php print $image->image_full;?>" <?php if ($k!=0){?>style="display:none"<?php }?> title="<?php print htmlspecialchars($image->_title)?>">
<img id = "main_image_<?php print $image->image_id?>" src = "<?php print $this->image_product_path?>/<?php print $image->image_name;?>" alt="<?php print htmlspecialchars($image->_title)?>" title="<?php print htmlspecialchars($image->_title)?>" />
<div class="text_zoom">
<img src="<?php print $this->path_to_image?>search.png" alt="zoom" />
<?php print _JSHOP_ZOOM_IMAGE?>
</div>
</a>


After:
<a class="lightbox" id="main_image_full_<?php print $image->image_id; ?>" href="<?php print $image->image_full; ?>" <?php if ($k!=0){?>style="display:none"<?php }?> title="<?php print htmlspecialchars($image->_title)?>" >
<img id = "main_image_<?php print $image->image_id?>" src = "<?php print $image->image_name;?>" alt="<?php print htmlspecialchars($image->_title)?>" title="<?php print htmlspecialchars($image->_title)?>" class="jshop_img_medium"/>
<div class="text_zoom">
<img src="<?php print $this->path_to_image?>search.png" alt="zoom" /> <?php echo _JSHOP_ZOOM_IMAGE?>
</div>
</a>



I haven't made any changes in admin area, because I add external images to database using my own component. External image URL must be saved into #__jshopping_products_images tabel on field "image_name".

I hope this is useful for other users also an maybe it will find the way to main version.


Joomla: 3.4.1
JoomShopping: 4.9.2
PHP: 5.5.12
MySQL: 5.6.17
Website Url: -
 
Copyrights MAXXmarketing GmbH. All Rights Reserved