/** * 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; }
/** * 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; }
/** * 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; }