Beg your pardon if this is a repeat question...I searched and couldn't find an answer.

Imagine this: using the Image and Image Gallery modules, I have a single gallery which will hold various images. Each image in this gallery will link to a different external site (that is, a different smugmug account).

I'm not afraid of changing my theme, so generating the output is the easy part (well, not easy, but I think I can do this). I think what might be hard is associating a URL with each image. I don't want to mod the Image and/or Image Gallery modules themselves to add a new variable for the URL.

How can I solve this puzzle? Thanks,

Eric

Comments

vm’s picture

I'd suggest using HTML and linking the images to the galleries. using the A and IMG tags and building a node with HTML that links to where you want it to go.

fersman4’s picture

I thought on this a while and came up with the following solution. It doesn't work in the general case, but it did in mine.

When I upload an image, I put the destination URL (prefixed with the appropriate "http://" string) alone in the 'Description' field. Drupal stores this in the node_revisions table and when the node is loaded later it will be in the 'body' field of $image.

Because I am using the PHPtemplate engine, I add an image_gallery.tpl.php to my theme directory. Forunately, I was basing my site off of box_grey so an image_gallery.tpl.php file already existed. I modified it so that instead of linking to "node/".$image->nid, it links to $image->body (but only if $image->body isn't null. Technically, this could link to bad places if the person adding the image isn't careful. But I don't let untrusted users add images).

Now when the gallery is loaded clicking the image links to the external site. You can still click on the image title to get to the image node.

The reason it doesn't work in the general case is:
1) Some people actually use the description field for a description of the image
2) A bad authenticated user could create a link to a bad place

I hope this is someday useful to someone.

Eric