summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-08-12 19:20:00 +0300
committerAndrew Dolgov <[email protected]>2019-08-12 19:20:00 +0300
commitbac38d9accde677203ccf08e120432521e947ecd (patch)
tree53721783a923b18c76790dad9481990f52eaf4b9
parentb9e0c4ade026c1b1a791090698c6f7abbd8ca62c (diff)
remove resize_enabled
-rw-r--r--README.md5
-rw-r--r--init.php5
2 files changed, 4 insertions, 6 deletions
diff --git a/README.md b/README.md
index 8359a75..cf019e1 100644
--- a/README.md
+++ b/README.md
@@ -3,10 +3,9 @@
Downsamples images if an API client requests the backend to do so. Useful for
slow or unreliable network connections, i.e. mobile internet.
-This plugin handles two additional parameters passed to ``getHeadlines`` or ``getArticle``
-API call:
+This plugin handles an additional parameter passed to ``getHeadlines``
+or ``getArticle`` API calls:
-* ``resize_enabled`` (bool) - enable or disable resizing
* ``resize_width`` (int) - target width (or height, plugin resizes based on a larger dimension)
Images are saved in a WEBP format.
diff --git a/init.php b/init.php
index bfe310e..3f01cf3 100644
--- a/init.php
+++ b/init.php
@@ -110,7 +110,7 @@ class Af_Zz_Api_Resize extends Plugin {
$flag_filename = CACHE_DIR . "/images/" . sha1($url) . ".flag";
$resized_filename = CACHE_DIR . "/images/" . sha1($url) . "-$width";
- if (!file_exists($flag_filename) || !$width) {
+ if (!file_exists($flag_filename) || $width <= 0) {
header("Location: $url");
return;
}
@@ -206,9 +206,8 @@ class Af_Zz_Api_Resize extends Plugin {
function hook_render_article_api($params) {
$need_saving = false;
$width = (int) clean($_REQUEST["resize_width"]);
- $enabled = sql_bool_to_bool(clean($_REQUEST["resize_enabled"]));
- if (!$enabled || !$width)
+ if ($width <= 0)
return $params["headline"];
$doc = new DOMDocument();