From c938e08853625a0ac39e3df725d677fc7ca96c7b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 7 May 2021 18:48:41 +0300 Subject: finish adding configurable webp quality --- init.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/init.php b/init.php index 1c037bd..cb0a914 100644 --- a/init.php +++ b/init.php @@ -118,13 +118,14 @@ class Api_Resize_Media extends Plugin { $flag_filename = sha1($url) . ".flag"; $resized_filename = sha1($url) . "-$width"; + $quality = $this->host->profile_get($this, "quality", self::DEFAULT_QUALITY); + if (!$this->cache->exists($flag_filename) || $width <= 0) { header("Location: $url"); return; } - if ($width > self::MAX_WIDTH) - $width = self::MAX_WIDTH; + if ($width > self::MAX_WIDTH) $width = self::MAX_WIDTH; if ($this->cache->exists($local_filename)) { @@ -138,7 +139,8 @@ class Api_Resize_Media extends Plugin { $width, $width, $this->cache->get_mime_type($local_filename), - $force_stamp); + $force_stamp, + $quality); if ($this->cache->exists($resized_filename)) { header("Location: " . $this->cache->get_url($resized_filename)); @@ -165,7 +167,8 @@ class Api_Resize_Media extends Plugin { $width, $width, $this->cache->get_mime_type($local_filename), - $force_stamp); + $force_stamp, + $quality); if ($this->cache->exists($resized_filename)) { header("Location: " . $this->cache->get_url($resized_filename)); @@ -371,7 +374,7 @@ class Api_Resize_Media extends Plugin { if ($args != "prefFeeds") return; $force_width = (int) $this->host->profile_get($this, "force_width", 0); - $quality = (int) $this->host->profile_get($this, "force_width", self::DEFAULT_QUALITY); + $quality = (int) $this->host->profile_get($this, "quality", self::DEFAULT_QUALITY); ?>