38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Classes;
|
|
|
|
use ApiLink;
|
|
|
|
trait ImageTrait {
|
|
|
|
public function getProductImage($id_image, $link_rewrite, $type = 'home') {
|
|
$img = (new ApiLink())->getImageLink($link_rewrite, $id_image, $type);
|
|
$image_name = str_replace($_SERVER['SERVER_NAME'], env('DOMAIN_STATIC'), $img);
|
|
|
|
//On utilise == false car on veut signifier : ( ==== false || === 0)
|
|
if (preg_match('/^(https:\/\/|http:\/\/)/', $image_name) == false) {
|
|
$image_name = 'https://'.$image_name;
|
|
}
|
|
return $image_name;
|
|
}
|
|
|
|
/**
|
|
* Get Image for a given sale
|
|
*
|
|
* @param $id_sale integer The id sales
|
|
* @param $active boolean Whether to return inactive image of the sale
|
|
*
|
|
* @return string url to the sale image
|
|
*/
|
|
public function getSaleImage($id_sale, $active = true) {
|
|
global $cookie;
|
|
|
|
$static = 'http://static.bebeboutik.com/';
|
|
|
|
$extension = $active === true ? 'mobile' : 'mobileoff';
|
|
return $static .
|
|
__PS_BASE_URI__.'modules/privatesales/img/' . $id_sale . '/' .
|
|
$extension . '_' . $cookie->id_lang . '.jpg';
|
|
}
|
|
} |