0

I have a list of images on my node that I want to output wrapped in an anchor tag for linking to external webpages. Images are coming from fields in my content type. I'm not using the Views or the Panels module, and I've edited my page.tpl.php and node.tpl.php files for a rather intricate "About Us" page.

So how do I do this? I'm using Drupal 7.

0

3 Answers 3

1

This is an updated answer to this question, not just for the original post as it was posted a year ago.

To perform this feature in Drupal 7, the module Image Link Formatter fits perfectly:

This module is the result of the discussions around a requested feature to allow an image field to be displayed with a link to a custom URL

1

You can create a custom field formatter (theme function for fields) where you can define how the image field should be rendered. Here you can add the a tag or any other special markup.

There are a lot of guides on how to do this, both here on the site and on the web, so I won't go into details about how to create a field formatter here, but it's nothing more than a few hooks and a theme function.

1

If you want to have the option to add a url to each image, there's a module Link Image Field for that. The port to Drupal 7 is not yet finished however (but it looks like there's working code).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.