Drupal - ImageCache Image Path

Kevin's picture

[b]Q:[/b] How can I get the path to an output [url=http://drupal.org/project/imagecache]ImageCache[/url] preset image given the path to the original input image?

[b]A:[/b] Use the [url=http://drupal.org/project/imagecache]ImageCache[/url] function imagecache_create_path() to get the path.

For example if your CCK node has a CCK image_field called 'field_entry_photo', then you can get the path to this image by using the following PHP code:


But, how can you get the path to the image after an imagecache preset has been applied to it? I found the answer in this [url=http://groups.drupal.org/node/20100]article[/url] - you just have to call imagecache_create_path() passing in the desired ImageCache preset name and the path to the source image, for example:

$url = imagecache_create_path('facebook_share_thumb',

I had to use this today when connecting one of our client's sites up to Facebook using the Facebook [url=http://developers.facebook.com/docs/opengraph]Open Graph Protocol[/url] - Image urls are often needed to enable the display of content thumbnails on Facebook. Sometimes Facebook mandates maximum image sizes etc so it is handy to use ImageCache to crop and scale the images before presenting them to Facebook - and hence the need to find the ImageCache paths!

Share this post: 

Recent Work

Some of Ireland's biggest brands use Pride Design to Design, Build, Manage, Market and Maintain their websites.

Website design for St.Patricks Credit Union in Dublin, Including Loan Calculators.

Website design and development for a step by step wedding and other stationary ordering website f

New website designed and developed for Cork's newest café, which is based in Merchants Quay in Co

New Website design for Pain Relief clinic based in Cork City.

Website for a busy Dublin city centre pub.

We redrafted the Ballymaloe house website to modernise the look and feel of the site and to also

We revamped the website for the Ballymaloe Cookery School.

We revamped the Cully & Sully website onto Drupal.

Rachel Allen was brought up in Dublin and left home at eighteen to study at the world-famous Ball

Clóna Dairy Products are a Dairy Company based in Clonakilty, Co. Cork, since 1919.

Project Arts Centre is Ireland’s leading centre for the presentation and development of c