diff --git a/src/application/controller/api/image.php b/src/application/controller/api/image.php index d0a4587..22b71dd 100755 --- a/src/application/controller/api/image.php +++ b/src/application/controller/api/image.php @@ -2,8 +2,20 @@ if (isset($_GET['hash'])) { - $icon = new Icon(); + $filename = md5($_GET['hash']); + $filepath = PROJECT_DIR . '/cache/image/' . $filename . '.jpeg'; + + if (!file_exists($filepath)) { + + $icon = new Icon(); + $image = $icon->generateImageResource($filename, 42, 42, false); + + file_put_contents($filepath, $image); + } + + $image = file_get_contents($filepath); header("Content-Type: image/jpeg"); - echo $icon->generateImageResource(md5($_GET['hash']), 42, 42, false); + + echo $image; } diff --git a/src/cache/image/index.html b/src/cache/image/index.html new file mode 100644 index 0000000..e69de29