/** * Add alternative Medium to this Medium. * * @param $ratio * @param Medium $alternative */ public function addAlternative($ratio, Medium $alternative) { if (!is_numeric($ratio) || $ratio === 0) { return; } $alternative->set('ratio', $ratio); $this->alternatives[(double) $ratio] = $alternative; }
/** * Add alternative Medium to this Medium. * * @param $ratio * @param Medium $alternative */ public function addAlternative($ratio, Medium $alternative) { if (!is_numeric($ratio) || $ratio === 0) { return; } $alternative->set('ratio', $ratio); $width = $alternative->get('width'); $this->alternatives[$width] = $alternative; }
/** * Save the image with cache. * * @return mixed|string */ protected function saveImage() { if (!$this->image) { return parent::path(false); } if (isset($this->result)) { return $this->result; } 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)); } return $this->image->cacheFile($this->format, $this->quality); }
/** * Reset medium. * * @return $this */ public function reset() { parent::reset(); $this->attributes['controls'] = true; return $this; }
/** * Construct. * @param array $attributes * @param Medium $medium */ public function __construct(array $attributes, Medium $medium) { $this->attributes = $attributes; $this->source = $medium->reset()->thumbnail('auto')->display('thumbnail'); $this->source->linked = true; }