× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

The best way of making an image field link in Drupal

Hugh Wormington
Jan 15, 2015
<p>Drupal's Link module provides a very flexible way of adding a link field to a content type, letter you specify the target and title attributes, but only supports text for the visible part.</p> <p>What if you want to show an image and link a click on the image to an arbitary URL? There are other modules that do this but none that offers the flexibility of the Link module.</p> <p>Along comes the excellently simple <a href="https://www.drupal.org/project/image_link_formatter">Image Link Formatter</a> module that gives you the best of both worlds, allowing you to attach a Link field to the image display.</p> <p>Install Link and Image Link Formatter modules, then create a content type and add a Link field (say "field_my_link"), and set its properties.</p> <p>Then add an image field (say "field_my_image").</p> <p>Now go to "Manage Display" for the content type, and set the format of the image field to "Image Link Formatter" and save.</p> <p>Now configure the <span style="color:rgb(95, 99, 102)">Image Link Formatter by clicking the cog on the image field and under "Link image to choose "My Link (field_my_link)". </span></p> <p><span style="color:rgb(95, 99, 102)">To hide the Link field change its display format to "Hidden".</span></p> <p><span style="color:rgb(95, 99, 102)">Save and you're done. Go create a node of this content type, enter a URL for the link field, upload and image for the image field, and save. </span></p> <p><span style="color:rgb(95, 99, 102)">Enjoy!</span></p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus