Im looking for some help with imagecache module!

I absolutely love the module. Works wonders for my site, but the problem I am trying to solve is, when the image appears and the "as link" is selected in the view display mode... The link goes to the Node that contains the image... this makes sense, but what I need it to do is link to something different. Anyone have any ideas how I can do this?

For example, the random generated images on the front page, when clicked, link into the "Gallery" page for the specific artist, because that is where the image sits... but.... I need to control the link and make it so it goes to the profile page of the images author...

Any suggestions?

Thanks Jonny

http://www.byronbayartists.com

Comments

nevets’s picture

In most case you should be able to theme the output, the details though depend on how the output is generated.

fighella’s picture

function theme_imagecache_formatter($field, $item, $formatter) {
if (preg_match('/_linked$/', $formatter)) {
$formatter = preg_replace('/_linked$/', '', $formatter);
$image = theme('imagecache', $formatter, $item['filepath'], $item['alt'], $item['title']);
$output = l($image, 'node/'. $item['nid'], array(), NULL, NULL, FALSE, TRUE);
}
else {
$output = theme('imagecache', $formatter, $item['filepath'], $item['alt'], $item['title']);
}
return $output;

Somewhere in the output I want to make it not node/ --- but user/ (whoever)

JD

nevets’s picture

First copy the function theme_imagecache_formatter to your themes template.php file, rename the function phptemplate_imagecache_formatter. Then this line

$output = l($image, 'node/'. $item['nid'], array(), NULL, NULL, FALSE, TRUE);

can be changed to

$node = node_load($item['nid']);
$output = l($image,'user/'. $node->uid, array(), NULL, NULL, FALSE, TRUE);
fighella’s picture

and what happens if my theme doesnt use a template.php file?

nevets’s picture

If your theme uses the phptemplate engine you can add a template.php if it does not already have one.

fighella’s picture

I just whacked it into the imagecache template and it seemed to work... err is that bad?

nevets’s picture

It makes upgrading a problem, since upgrading the module would overwrite your changes.

fighella’s picture

so im assuming , my install looks for the function in the template.php file first... then in module?

nevets’s picture

Basically yes

basicmagic.net’s picture

subscribe

Drupal samurai for hire, based in Buffalo, New York, USA.
15+ years Drupal, 20+ years web.
http://basicmagic.net