Add double-density support to photo thumbnails #28

Merged
Aaron merged 13 commits from improve_thumbs into master 2022-11-27 14:38:22 +01:00
Showing only changes of commit 1c02cbea93 - Show all commits

View File

@ -67,18 +67,20 @@ class Image extends Asset
return EXIF::fromFile($this->getPath()); return EXIF::fromFile($this->getPath());
} }
public function getInlineImage($width = null, $height = null, $className = '') public function getInlineImage($width = null, $height = null, $className = 'inline-image')
{ {
if (isset($width) && isset($height)) $image_urls = [];
$image_url = $this->getThumbnailUrl($width, $height, false); if (isset($width) || isset($height))
elseif (isset($width)) {
$image_url = $this->getThumbnailUrl($width, null, false); $thumbnail = new Thumbnail($this);
elseif (isset($height)) $image_urls[1] = $this->getThumbnailUrl($width, $height, false);
$image_url = $this->getThumbnailUrl(null, $height, false); $image_urls[2] = $this->getThumbnailUrl($width * 2, $height * 2, false);
}
else else
$image_url = $this->getUrl(); $image_urls[1] = $this->getUrl();
return '<img class="inline-image ' . $className . '" src="' . $image_url . '" alt="">'; return '<img class="' . $className . '" src="' . $image_urls[1] . '" alt=""' .
(isset($image_urls[2]) ? ' srcset="' . $image_urls[2] . ' 2x"' : '') . '>';
} }
/** /**