I am using image cache and image to add photos to our website - see www.shelfanger.com. Having uploaded the image (mostly 640x480) it shows a main image of 300px wide and a thumbnail 100x100. But when you read the story it would be great if clicking on the main image (files/imagecache/mainimage/files/image2.jpg) in the story - automatically opened a new browser window and showed the original uploaded image (/files/image2.jpg). Otherwise they are a useless resource.
any guidance please??

Comments

quicksketch’s picture

Override the theme_imagecache function in your template.php file. Then you can make all images displayed by imagecache link to the original if you so wish.

Paste this into you template.php file and modify as necessary.

function phptemplate_imagecache($namespace, $path, $alt = '', $title = '', $attributes = NULL) {
  $attributes = drupal_attributes($attributes);
  $imagecache_path =  file_create_url(file_directory_path() .'/imagecache/'. $namespace .'/'. $path);
  $img = '<img src="'. $imagecache_path .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $attributes .' />';
  if ($namespace == 'mainimage') {
    $img = '<a href="' . $path . '"> ' . $img . '</a>';
  }
  return $img;
}
artatac’s picture

Thanks for this. I am using garland theme. cant find theme_ImageCache function in template.php. If I put your code in the template php it breaks the site. I cannot see anything I would need to alter. any further guidance please? Is this a feature that may be included in a future relaese?

best wishes - Joe

benedett’s picture

You can do this using the Content Template module.

See this article for details:
http://drupal.org/node/101710#comment-177969

I'm not convinced that this functionality belongs in imagecache, since different people will want to tweak it in different ways, and Content Template allows that tweaking already.

quicksketch’s picture

Hmm, you should take a look at the theming handbook for instructions on how to use the theming system in Drupal. In a nutshell, you can take any function beginning with theme_, copy it and put it in your template.php file. Rename the function from theme_ to garland_ (or the name of your theme). The copy you put in your template.php will be called instead of the original function.

For more: http://drupal.org/node/55126.

dopry’s picture

Status: Active » Closed (fixed)

Or you can write a module that implements an imagefield formatter.