/** * Releases a image id in Prestashop. It requires the image name. * * @param string $name_photo * @param integer $language * @return a empty string if the name has not been found, else integer. * */ public function getIdImageByName($name_photo, $language = 1) { $id = ""; $image = new ImageCore(); $array_all_images = $image->getAllImages(); $tmp = explode(".", $name_photo); $name_photo_product = ""; if (count($tmp) == 1) { $name_photo_product = $name_photo . ".jpg"; } else { $name_photo_product = $name_photo; } foreach ($array_all_images as $array_single_image) { $array_image = new ImageCore((int) $array_single_image['id_image']); $image_name = $array_image->legend; if (strtolower($image_name[$language]) === strtolower($name_photo_product)) { $id = (int) $array_image->id; break; } } return (int) $id; }