Wrap a link around an image in a render array
When you want to make an image clickable and you're dealing with a render array, these are the properties to add to it. Mind the highlighted lines.
As long as you're dealing with the theme function 'image_formatter', you can use the #path property to wrap a link around it.
Because I didn't find it in a snap on the web, I'm posting it here, not to forget.
As long as you're dealing with the theme function 'image_formatter', you can use the #path property to wrap a link around it.
Because I didn't find it in a snap on the web, I'm posting it here, not to forget.
<?php $build['image'] = array( '#theme' => 'image_formatter', '#item' => array( 'uri' => 'misc/druplicon.png', ), '#path' => array( 'path' => 'node/1', 'options' => array('html' => TRUE), // Optional. ), ); ?>Source: http://data.agaric.com/wrapping-link-around-renderable-array-images-drupal-7
Add new comment