コード例 #1
0
ファイル: ImageType.php プロジェクト: yiuked/tmcart
 public function reloadImages()
 {
     $dir = _TM_PRO_IMG_DIR;
     $productsImages = Image::getAllImages();
     foreach ($productsImages as $k => $image) {
         $imageObj = new Image($image['id_image']);
         //echo $dir.$imageObj->getExistingImgPath().'.jpg';
         if (file_exists($dir . $imageObj->getExistingImgPath() . '.jpg')) {
             if (!ImageCore::imageResize($dir . $imageObj->getExistingImgPath() . '.jpg', $dir . $imageObj->getExistingImgPath() . '-' . stripslashes($this->name) . '.jpg', (int) $this->width, (int) $this->height)) {
                 $errors = true;
             }
         }
     }
 }
コード例 #2
0
 public static function GenUserPortraits($pic, $filename, $pic_target, $pic_ext)
 {
     global $nw_uid;
     $img_info = getimagesize($pic_target);
     $pic_d = AVATAR_DIR . '/l/' . GlobalCore::mkdir_by_uid($nw_uid, NOWHERE_ROOT . AVATAR_DIR . '/l') . '/' . $filename . '.jpg';
     $pic_m = AVATAR_DIR . '/m/' . GlobalCore::mkdir_by_uid($nw_uid, NOWHERE_ROOT . AVATAR_DIR . '/m') . '/' . $filename . '.jpg';
     $pic_s = AVATAR_DIR . '/s/' . GlobalCore::mkdir_by_uid($nw_uid, NOWHERE_ROOT . AVATAR_DIR . '/s') . '/' . $filename . '.jpg';
     @ImageCore::vxResize($pic, $pic_d, 75, 75, 1 | 4, 2);
     @ImageCore::vxResize($pic, $pic_m, 48, 48, 1 | 4, 2);
     @ImageCore::vxResize($pic, $pic_s, 32, 32, 1 | 4, 2);
     if ($pic_ext != 'jpg') {
         @unlink($pic_target);
     }
 }
コード例 #3
0
 /**
  * Get an image
  *
  * @param int $id_image
  *
  * @return object
  */
 public function getImage($id_image)
 {
     $imageData = new \ImageCore((int) $id_image);
     return ['id' => $imageData->id, 'id_product' => $imageData->id_product, 'position' => $imageData->position, 'cover' => $imageData->cover ? true : false, 'legend' => $imageData->legend, 'format' => $imageData->image_format, 'base_image_url' => _THEME_PROD_DIR_ . $imageData->getImgPath()];
 }
コード例 #4
0
 /**
  * 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;
 }
コード例 #5
0
 /**
  * Update image legend and cover
  *
  * @param int $idImage
  * @param array $data
  *
  * @return object image
  */
 public function ajaxProcessUpdateImage($idImage, $data)
 {
     $img = new \ImageCore((int) $idImage);
     if ($data['cover']) {
         \ImageCore::deleteCover((int) $img->id_product);
         $img->cover = 1;
     }
     $img->legend = $data['legend'];
     $img->update();
     return $img;
 }