+ function cache_enclosures($enclosures, $site_url, $debug) {
+ foreach ($enclosures as $enc) {
+
+ if (preg_match("/(image|audio|video)/", $enc[1])) {
+
+ $src = rewrite_relative_url($site_url, $enc[0]);
+
+ $local_filename = CACHE_DIR . "/images/" . sha1($src);
+
+ if ($debug) _debug("cache_enclosures: downloading: $src to $local_filename");
+
+ if (!file_exists($local_filename)) {
+ $file_content = fetch_file_contents($src);
+
+ if ($file_content && strlen($file_content) > _MIN_CACHE_FILE_SIZE) {
+ file_put_contents($local_filename, $file_content);
+ }
+ } else {
+ touch($local_filename);
+ }
+ }
+ }
+ }
+