Prestashop 1.5.6 Link::getImageLink returns unexpected value

Pablo picture Pablo · Nov 10, 2014 · Viewed 7.5k times · Source

I'm calling

$imagePath = Link::getImageLink($product->link_rewrite, $id_product, 'home_default');

For example, when the $id_product is 150 , it returns websitepath/img/p/1/5/0/150-home_default.jpg . But when I see the real image_link created for that product id with the browser view source option it's websitepath/img/p/1/2/5/125-home_default.jpg . Isnt that code supposed to return the image links for a product?

Greetings

Answer

Ophiuchus picture Ophiuchus · Sep 9, 2016

In Prestashop 1.6, getImageLink shouldn't be call statically

$image = Product::getCover((int)$data['id_product']);
$link = new Link;//because getImageLInk is not static function
$data['imagePath'] = $image ? 'http://'.$link->getImageLink($data['link_rewrite'], $image['id_image'], 'medium_default') : false;