Jump to content

Product thumbnail image invalid path

Recommended Posts

Hello guys,

I want to display the thumbnail of a given Product within an Admin page built with symfony. I am doing it this way:

$product = new Product($id, false, $lang);
$imageProduct = new Image($product->getCover($id)['id_image']);
$img = ImageManager::thumbnail(
  _PS_IMG_DIR_ . 'p/' . $imageProduct->getExistingImgPath() . '.jpg',
  'product_small_' . $id . '.jpg',

the result is:

<img src="../img/tmp/product_small_1.jpg?time=1599958131" alt="" class="imgm img-thumbnail">


but the path is invalid, this one works :



Do you know why I don't get the correct path in the first place ? Am I doing it wrong ?

Share this post

Link to post
Share on other sites

ok it seems the proper way to do this is:


$product = new Product($id, false, $lang);
$img = $product->getCover($id);
$url = Context::getContext()->link->getImageLink(isset($product->link_rewrite) ? $product->link_rewrite : $product->name, (int) $img['id_image'], 'small_default');


Edited by Archalia (see edit history)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More