Browse Source

implement avatar image cache

main
ghost 3 years ago
parent
commit
a06afb19cd
  1. 14
      src/application/controller/api/image.php
  2. 0
      src/cache/image/index.html

14
src/application/controller/api/image.php

@ -2,8 +2,20 @@ @@ -2,8 +2,20 @@
if (isset($_GET['hash'])) {
$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;
}

0
src/cache/image/index.html vendored

Loading…
Cancel
Save