From 16276f3b061e6d246d46e4b7d6ed7fadca4225f4 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 16 Jun 2014 21:50:28 +0200 Subject: [PATCH] privacy_image_cache: Support of sizes like Twitter --- privacy_image_cache/privacy_image_cache.php | 27 ++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/privacy_image_cache/privacy_image_cache.php b/privacy_image_cache/privacy_image_cache.php index b7c8fc7a..a0cd8107 100644 --- a/privacy_image_cache/privacy_image_cache.php +++ b/privacy_image_cache/privacy_image_cache.php @@ -61,6 +61,7 @@ function privacy_image_cache_init() { } $thumb = false; + $size = 1024; // If the cache path isn't there, try to create it if (!is_dir($_SERVER["DOCUMENT_ROOT"]."/privacy_image_cache")) @@ -79,6 +80,20 @@ function privacy_image_cache_init() { else $url = $a->argv[1]; + //$thumb = (isset($a->argv[3]) and ($a->argv[3] == "thumb")); + if (isset($a->argv[3]) and ($a->argv[3] == "thumb")) + $size = 200; + + // thumb, small, medium and large. + if (substr($url, -6) == ":thumb") + $size = 150; + if (substr($url, -6) == ":small") + $size = 340; + if (substr($url, -7) == ":medium") + $size = 600; + if (substr($url, -6) == ":large") + $size = 1024; + $pos = strrpos($url, "=."); if ($pos) $url = substr($url, 0, $pos+1); @@ -89,7 +104,6 @@ function privacy_image_cache_init() { if ($url) $_REQUEST['url'] = $url; - $thumb = (isset($a->argv[3]) and ($a->argv[3] == "thumb")); } if (!$direct_cache) { @@ -186,10 +200,10 @@ function privacy_image_cache_init() { if (!$direct_cache AND ($cachefile == "")) $img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100); - if ($thumb) { - $img->scaleImage(200); // Test - $img_str = $img->imageString(); - } + //if ($thumb) { + // $img->scaleImage(200); // Test + // $img_str = $img->imageString(); + //} } //$mime = "image/jpeg"; } @@ -199,7 +213,8 @@ function privacy_image_cache_init() { if ($mime != "image/gif") { $img = new Photo($img_str, $mime); if($img->is_valid()) { - $img->scaleImage(1024); // Test + //$img->scaleImage(1024); // Test + $img->scaleImage($size); $img_str = $img->imageString(); } }