+
+ // $scale_replace, if passed, is an array of two elements. The
+ // first is the name of the full-size image. The second is the
+ // name of a remote, scaled-down version of the full size image.
+ // This allows Friendica to display the smaller remote image if
+ // one exists, while still linking to the full-size image
+ if($scale_replace)
+ $scaled = str_replace($scale_replace[0], $scale_replace[1], $mtch[1]);
+ else
+ $scaled = $mtch[1];
+ $i = fetch_url($scaled);
+
+ $cache = get_config('system','itemcache');
+ if (($cache != '') and is_dir($cache)) {
+ $cachefile = $cache."/".hash("md5", $scaled);
+ file_put_contents($cachefile, $i);
+ }
+