Browse Source

added cache time to cacheImage function

CauseFX 6 years ago
parent
commit
c778e2e8f9
1 changed files with 4 additions and 1 deletions
  1. 4 1
      api/functions/organizr-functions.php

+ 4 - 1
api/functions/organizr-functions.php

@@ -2067,7 +2067,10 @@ function cacheImage($url, $name, $extension = 'jpg')
         mkdir($cacheDirectory, 0777, true);
     }
     $cachefile = $cacheDirectory . $name . '.' . $extension;
-    @copy($url, $cachefile);
+	$cachetime = 604800;
+	if ((file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) || !file_exists($cachefile)) {
+		@copy($url, $cachefile);
+	}
 }
 
 function downloader($array)