About

Imagecache External is a utility module to allow you to use imagecache(D6) / Image Styles (D7) with external images.

Installation

  1. Extract the module to sites/all/modules or sites/xx/modules depending on whether or not you have a multisite installation.
  2. Enable the module at admin/modules or use drush.

Configuration

The module's default configuration is very restrictive. Exclude admin user or users with the 'Bypass black/white list' permission - the default configuration of the module is to deny all requests to fetch external images.

To get the module to work, you need to visit
admin/config/media/imagecache_external and either:

  • Add some domains to the whitelist -or-
  • Switch the mode of operation from whitelist to blacklist

Usage instructions

Drupal 7

Usage is simplified in Drupal 7 as follows:

<?php
 
print theme('imagecache_external', array(
   
'path' => 'http://larsjung.de/h5ai/sample/screenshots/h5ai-v0.7-icons.png',
   
'style_name'=> 'thumbnail',
   
'alt' => 'An alternative description',
));
?>

or by using a render array:

<?php
 
return array(
   
'#theme' => 'imagecache_external',
   
'#path' => 'http://larsjung.de/h5ai/sample/screenshots/h5ai-v0.7-icons.png',
   
'#style_name' => 'thumbnail',
   
'#alt' => 'An alternative description',
  );
?>

You can also use external images without coding at all by adding an Text or Link field to a Node Type and then use the Imagecache External Image formatter.

Thanks to manu manu for the D7 port.

Permissions

The module provides various permissions - most importantly

  • View external images
  • Fetch external images

If you're not getting the expected results for anonymous users, make sure you have these set the way you need them.
For an external image to be used with imagecache, it has to be fetched and cached at least once. If the image has not been fetched and the requesting user does not have the 'fetch external images' permission, then it won't work - the image won't be fetched (in fact a 403 error will occur).

Other notes

Images are fetched using drupal_http_request so if your server is not configured properly (view the status report) this won't work.
Images are stored in the site's files folder in an external subdirectory.
You may flush the fetched external images (note that this does not flush the generated imagecache files) by visiting admin/settings/imagecache_externals/flush.

Project Information

Downloads