cacheFile() public method

Note that if it exists, all the image computation process will not be done.
public cacheFile ( string $type = 'jpg', integer $quality = 80, $actual = false )
$type string the image type
$quality integer the quality (for JPEG)
Ejemplo n.º 1
0
 /**
  * Return URL to file.
  *
  * @return string
  */
 public function url()
 {
     if ($this->image) {
         $output = $this->image->cacheFile($this->type, $this->quality);
         $this->reset();
     } else {
         $relPath = preg_replace('|^' . ROOT_DIR . '|', '', $this->get('path'));
         $output = $relPath . '/' . $this->get('filename');
     }
     return self::$grav['base_url'] . '/' . $output;
 }
Ejemplo n.º 2
0
 /**
  * Return URL to file.
  *
  * @return string
  */
 public function url()
 {
     /** @var Config $config */
     $config = self::$grav['config'];
     if ($this->image) {
         $output = $this->image->cacheFile($this->type, $this->quality);
         $this->reset();
     } else {
         $relPath = preg_replace('|^' . ROOT_DIR . '|', '', $this->get('path'));
         $output = $relPath . '/' . $this->get('filename');
     }
     return $config->get('system.base_url_relative') . '/' . $output;
 }
Ejemplo n.º 3
0
 /**
  * Save the image with cache.
  *
  * @return mixed|string
  */
 protected function saveImage()
 {
     if (!$this->image) {
         return parent::path(false);
     }
     if ($this->get('debug') && !$this->debug_watermarked) {
         $ratio = $this->get('ratio');
         if (!$ratio) {
             $ratio = 1;
         }
         $locator = self::$grav['locator'];
         $overlay = $locator->findResource("system://assets/responsive-overlays/{$ratio}x.png") ?: $locator->findResource('system://assets/responsive-overlays/unknown.png');
         $this->image->merge(ImageFile::open($overlay));
     }
     $result = $this->image->cacheFile($this->format, $this->quality);
     return $result;
 }