Get product image path

  • Posts: 71
  • Thank you received: 0
10 years 1 week ago #213113

-- 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!

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.

  • Posts: 26274
  • Thank you received: 4045
  • MODERATOR
10 years 1 week ago #213119

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.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 71
  • Thank you received: 0
10 years 1 week ago #213198

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.

  • Posts: 13201
  • Thank you received: 2322
10 years 1 week ago #213200

Hi,

You can use it like that:

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.052 seconds
Powered by Kunena Forum