diff --git a/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php b/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php index 274a2fd18..eab9b7361 100644 --- a/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php +++ b/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php @@ -280,6 +280,24 @@ trait ImageMediaTrait return $this; } + /** + * Allows to set the loading attribute from Markdown or Twig + * + * @param string|null $value + * @return $this + */ + public function loading($value = null) + { + if (is_null($value)) { + $value = Grav::instance()['config']->get('images.defaults.loading', 'auto'); + } + if ($value && $value !== 'auto') { + $this->attributes['loading'] = $value; + } + + return $this; + } + /** * Filter image by using user defined filter parameters. * diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index 2e4c4f9bf..5f9b22ab3 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -247,120 +247,6 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate return parent::lightbox($width, $height, $reset); } - /** - * Sets or gets the quality of the image - * - * @param int $quality 0-100 quality - * @return int|$this - */ - public function quality($quality = null) - { - if ($quality) { - if (!$this->image) { - $this->image(); - } - - $this->quality = $quality; - - return $this; - } - - return $this->quality; - } - - /** - * Sets image output format. - * - * @param string $format - * @return $this - */ - public function format($format) - { - if (!$this->image) { - $this->image(); - } - - $this->format = $format; - - return $this; - } - - /** - * Set or get sizes parameter for srcset media action - * - * @param string $sizes - * @return string - */ - public function sizes($sizes = null) - { - - if ($sizes) { - $this->sizes = $sizes; - - return $this; - } - - return empty($this->sizes) ? '100vw' : $this->sizes; - } - - /** - * Allows to set the width attribute from Markdown or Twig - * Examples: ![Example](myimg.png?width=200&height=400) - * ![Example](myimg.png?resize=100,200&width=100&height=200) - * ![Example](myimg.png?width=auto&height=auto) - * ![Example](myimg.png?width&height) - * {{ page.media['myimg.png'].width().height().html }} - * {{ page.media['myimg.png'].resize(100,200).width(100).height(200).html }} - * - * @param mixed $value A value or 'auto' or empty to use the width of the image - * @return $this - */ - public function width($value = 'auto') - { - if (!$value || $value === 'auto') { - $this->attributes['width'] = $this->get('width'); - } else { - $this->attributes['width'] = $value; - } - - return $this; - } - - /** - * Allows to set the height attribute from Markdown or Twig - * Examples: ![Example](myimg.png?width=200&height=400) - * ![Example](myimg.png?resize=100,200&width=100&height=200) - * ![Example](myimg.png?width=auto&height=auto) - * ![Example](myimg.png?width&height) - * {{ page.media['myimg.png'].width().height().html }} - * {{ page.media['myimg.png'].resize(100,200).width(100).height(200).html }} - * - * @param mixed $value A value or 'auto' or empty to use the height of the image - * @return $this - */ - public function height($value = 'auto') - { - if (!$value || $value === 'auto') { - $this->attributes['height'] = $this->get('height'); - } else { - $this->attributes['height'] = $value; - } - - return $this; - } - - public function loading($value = null) - { - if (is_null($value)) { - $value = Grav::instance()['config']->get('images.defaults.loading', 'auto'); - } - if ($value && $value !== 'auto') { - $this->attributes['loading'] = $value; - } - - return $this; - } - /** * Forward the call to the image processing method. *