I've successfuly installed the Image module and I can now attach images to stories. But the thumbnail in the story links to the story itself. How do I change it to link to the preview version of this image?

Comments

dvessel’s picture

You have to override it through the template.php file. It's not hard to do but if you don't have any experience with php, it can be confusing. I know it confused me..

http://drupal.org/node/55126

You'll find the function inside the "image.module" file. Search for image_teaser and copy that whole function to your template.php file. Make sure you rename the function phptemplate_image_teaser.

Inside that function you'll see a l() -link fuction. You can look it up here:

http://api.drupal.org/api/4.7/function/l

Once you figure out how it works and the way the image function works, change the copy of the image function inside the template.php file to your liking.

Good luck

joon

jan.horcik’s picture

thanks, I've tried this but it doesn't seem to be working. I've changed the $path variable in l() function in the template.php file but the image still links to the story itself. in fact I'm not completely sure with the $path var - what should it look like if I want to link to the preview version of this image?

dvessel’s picture

First off, did you go into yoursite.com/admin/settings and hit apply? I'm not 100% sure if that's necessary but it could be cached and that's supposed to reset it. One of those odd quirks.

You just wanted to link directly to the preview version with no surrounding html? This would do it.

function phptemplate_image_teaser($node) {
 return l(image_display($node, 'thumbnail'), NULL, NULL, 'q=image/view/'.$node->nid.'/_preview', FALSE, TRUE) . $node->teaser;
}

The 4th item inside l() is for query which will call the image directly. Make sure you NULL the 'path'.

joon