Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There's a special imagefield link module; however, if your site has developed with either of the separate fields alone to begin with, converting your data is perhaps not an option.
You can format an imagefield to display as a link with the URL from a link field by creating a field template for your image field like this:
<?php
if (!empty($view->field['field_YOUR_LINK_FIELD_url']->field_alias)) {
$data = $row->{$view->field['field_YOUR_LINK_FIELD_url']->field_alias};
$url = link_cleanup_url($data);
//dsm($url);
}
?>
<?php if ($url) : ?>
<a href="<?php print $url; ?>">
<?php print $output; ?>
</a>
<?php else : ?>
<?php print $output; ?>
<?php endif; ?>