Skip to main content

Get product image path

More
11 years 1 month ago #213113 by bmichu
-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.1

Hi,

I have following code for displaying product images in the banner of the each product page. Unfortunately it's displaying the absolute path (/home/florenti/public_html/media/com_hikashop/upload//product_main/main_Prod-Baldrian.jpg) and it needs the realtive path (media/com_hikashop/upload/product_main) to display correctly. How do I change the code below to make this work?

Thanks!
Code:
if (!empty ($this->element->images) && count($this->element->images) > 1) { foreach ($this->element->images as $image) { if(strpos($image->file_description,"main")) { $fileClass = hikashop_get('class.file'); $mainPath = $fileClass->getPath('image'); $_POST["banner"]= '<div class="flo_product_mainimage" ><img style="max-width: 100%;" title="'.$this->escape(@$image->file_description).'" alt="'.$this->escape(@$image->file_name).'" src="' . $mainPath.$image->file_path . '"/></div>';

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #213119 by Jerome
Replied by Jerome on topic Get product image path
Hi,

Use " HIKASHOP_IMAGES " constant instead.
The function getPath is there to gave a file page ; not an URL.

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #213198 by bmichu
Replied by bmichu on topic Get product image path
Hi Jerome,

Thanks for the reply!
Could you give me an example how I would use the "HIKASHOP_IMAGES " constant ?

Thanks,
Michel

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #213200 by Xavier
Replied by Xavier on topic Get product image path
Hi,

You can use it like that:
Code:
echo HIKASHOP_IMAGES.$image->file_path;
The following user(s) said Thank You: bmichu

Please Log in or Create an account to join the conversation.

Time to create page: 0.229 seconds
Powered by Kunena Forum