Exemplo n.º 1
0
 public function getUrl()
 {
     if ($this->_imageShouldComeFromCloudinary($this->_newFile)) {
         $imageProvider = CloudinaryImageProvider::fromConfiguration($this->_getConfigHelper()->buildConfiguration());
         return (string) $imageProvider->transformImage(Image::fromPath($this->_newFile));
     }
     return parent::getUrl();
 }
Exemplo n.º 2
0
 public function __toString()
 {
     $imageFile = $this->_getRequestedImageFile();
     if ($this->_imageShouldComeFromCloudinary($imageFile)) {
         $image = Image::fromPath($imageFile);
         $transformation = $this->_configuration->getDefaultTransformation()->withDimensions($this->_dimensions);
         return (string) $this->_imageProvider->transformImage($image, $transformation);
     }
     return parent::__toString();
 }
Exemplo n.º 3
0
 protected function _afterSave($result)
 {
     parent::_afterSave($result);
     if (!empty($result['path']) && !empty($result['file'])) {
         $imageProvider = CloudinaryImageProvider::fromConfiguration($this->_getConfigHelper()->buildConfiguration());
         $imageProvider->upload(Image::fromPath($result['path'] . DIRECTORY_SEPARATOR . $result['file']));
         $this->_trackSynchronisation($result['file']);
     }
     return $this;
 }
Exemplo n.º 4
0
 public function getThumbnailUrl($filePath, $checkFile = false)
 {
     if ($this->_imageShouldComeFromCloudinary($filePath)) {
         $imageProvider = $this->_buildImageProvider();
         $imageDimensions = $this->_buildImageDimensions();
         $defaultTransformation = $this->_getConfigHelper()->buildConfiguration()->getDefaultTransformation();
         return (string) $imageProvider->transformImage(Image::fromPath($filePath), $defaultTransformation->withDimensions($imageDimensions));
     }
     return parent::getThumbnailUrl($filePath, $checkFile);
 }
 private function uploadImage(Synchronizable $image)
 {
     try {
         $this->imageProvider->upload(Image::fromPath($this->getAbsolutePath($image)));
         $image->tagAsSynchronized();
         $this->countMigrated++;
         $this->logger->notice(sprintf(self::MESSAGE_UPLOADED, $image->getFilename()));
     } catch (\Exception $e) {
         $this->logger->error(sprintf(self::MESSAGE_UPLOAD_ERROR, $e->getMessage(), $image->getFilename()));
     }
 }
 function it_logs_an_error_if_any_of_the_image_uploads_fails(ImageProvider $imageProvider, Logger $logger, Synchronizable $image1, Synchronizable $image2)
 {
     $image1->getFilename()->willReturn('/z/b/image1.jpg');
     $image2->getFilename()->willReturn('/invalid');
     $exception = new \Exception('Invalid file');
     $images = array($image1, $image2);
     $imageProvider->upload(Image::fromPath('/catalog/media/invalid'))->willThrow($exception);
     $imageProvider->upload(Image::fromPath('/catalog/media/z/b/image1.jpg'))->shouldBeCalled();
     $this->uploadImages($images);
     $image1->tagAsSynchronized()->shouldHaveBeenCalled();
     $image2->tagAsSynchronized()->shouldNotHaveBeenCalled();
     $logger->error(sprintf(BatchUploader::MESSAGE_UPLOAD_ERROR, $exception->getMessage(), '/invalid'))->shouldHaveBeenCalled();
     $logger->notice(sprintf(BatchUploader::MESSAGE_STATUS, 1))->shouldHaveBeenCalled();
 }
 /**
  * @Then the image provider should use multiple sub-domains
  */
 public function theImageProviderShouldUseMultipleSubDomains()
 {
     $request1 = $this->imageProvider->transformImage(Image::fromPath('somePath'), Transformation::builder());
     $request2 = $this->imageProvider->transformImage(Image::fromPath('someOtherPath'), Transformation::builder());
     expect($this->requestPrefixIsTheSame($request1, $request2))->toBe(false);
 }
 public function deleteImage(Image $image)
 {
     Uploader::destroy($image->getId());
 }
Exemplo n.º 9
0
 private function _getUrlForImage($file)
 {
     $imageProvider = CloudinaryImageProvider::fromConfiguration($this->_getConfigHelper()->buildConfiguration());
     return (string) $imageProvider->transformImage(Image::fromPath($file));
 }
 /**
  * @Transform :anImage
  */
 public function transformStringToAnImage($string)
 {
     return Image::fromPath($string);
 }
Exemplo n.º 11
0
 public function getUrl($imagePath)
 {
     $imageProvider = $this->_getImageProvider();
     return (string) $imageProvider->transformImage(Image::fromPath($imagePath));
 }