Пример #1
0
 /**
  * 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;
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * 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);
 }
Пример #4
0
 /**
  * Reset medium.
  *
  * @return $this
  */
 public function reset()
 {
     parent::reset();
     $this->attributes['controls'] = true;
     return $this;
 }
Пример #5
0
 /**
  * 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;
 }