Beispiel #1
0
 /**
  * Return ImageNameScript and file for no-image image
  * @return array
  */
 public function getNoImage($return_image = FALSE)
 {
     $script = ImageNameScript::fromIdentifier($this->noimage_identifier);
     $file = implode('/', [$this->data_path, $script->original]);
     if (!file_exists($file)) {
         $identifier = '_storage_no_image/8f/no_image.png';
         $new_path = "{$this->data_path}/{$identifier}";
         if (!file_exists($new_path)) {
             $data = base64_decode(require __DIR__ . '/NoImageSource.php');
             $_image = Nette\Utils\Image::fromString($data);
             $_image->save($new_path, $script->quality ?: $this->quality);
         }
         if ($return_image) {
             return new Image($this->friendly_url, $this->data_dir, $this->data_path, $identifier);
         }
         $script = ImageNameScript::fromIdentifier($identifier);
         return [$script, $new_path];
     }
     if ($return_image) {
         return new Image($this->friendly_url, $this->data_dir, $this->data_path, $this->noimage_identifier);
     }
     return [$script, $file];
 }
Beispiel #2
0
 public function getScript()
 {
     return $this->script ?: ImageNameScript::fromIdentifier($this->identifier);
 }