Search

I've been looking for a way of dealing with external images neatly in S2 and Alistair kindly helped me out by providing this addition to the image.php file:

  ## Cache the external images for 1 day (24 * 60 * 60)

elseif($param['external'] == '1' && CACHING){

    $cache_file = CACHE . '/' . md5($_REQUEST['param'] . $quality) . "_" . basename($image_path);   

    if(@is_file($cache_file) && (@filemtime($cache_file) < (time() - (24 * 60 * 60)))){ 
        unlink($cache_file);
    }       

    elseif(is_file($cache_file)){
        $image_path = $cache_file;
        @touch($cache_file);
        $param['mode'] = MODE_NONE;
        $param['external'] = 0;
    }
}

If you add that in around line 55 in /symphony/image.php external images called through the Symphony image function will be cached for 24 hours — the idea being that if you're using Flickr or similar to manage your external images, then you won't have to deal with the processing overhead from modifying each image on the fly each time. As an added bonus, if Flickr goes down during your cache period your images will still show up.

Thanks for posting it Makenosound

Yeah thanks for that! Much-o usefulness! :)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details