Output an image as a link with the Drupal l function

By shane
Wed, 2011-09-21 15:58

Share with Others

The l function in Drupal is an easy way to output a link. If you need to add html within the link you can set an array with the correct options.

Here are a couple of examples using the l function.

l('<img src="/my/image/path.png" />', 'image/path', array('html' => TRUE));

You can also add classes to a link using the l function:

l('link text', 'link/path', array('attributes' => array('class' => 'my-class')));