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:
It seems many attempts and implementations have already been proposed:
- Link Image Field
- Link Image Formatter
- Other solutions: Custom Formatters:
#1397700: [SOLVED} Error in src in Image formatter for link field or through theming options.
- Indirect solution through the setup of Linked Field with Tokens [Requires: Field Formatter Settings].
This module has no pretention of implementing any field, it's just a formatter (display) to combine the Image field (Drupal 7 Core) and Link field (contrib).
The idea behind this is to provide a simple solution, easy to setup, with few dependencies and trying to leverage the flexibility and robustness of the Link field module, since it offers already very comprehensive URL validation options or link rendering settings.
Combined with the Image field in core for better compatibility and easier support.
The code is greatly inspired from the post: #1570072: Ability to customize image links where a patch has been proposed, against the Drupal 7 Core Image field.
So this module is simply a copy of the Image core formatter functions, with the patch applied and a few more fixes, mostly to support field translation.
It seems this function could also be achieved by using Custom Formatters (See module's tracker page for more information, image with custom link formatter is a recurring topic).
Another solution would be to use the Linked Field module which pretty much allows linking any field to custom URL targets with Token patterns. In other words, almost the same functionality could be obtained with a little bit more complicated setup with the Linked Field module configured with Tokens (Main difference would be the handling of the Link field settings upon display of the formatter).
But since this is a recurring request with such a simple and light implementation, it could be considered as a standalone module.
A pretty cool and simple setup or application of this module would be, for example, to build a simple ads block, with an image linking to a custom URL in a block:
Add a Bean block type with Image and Link fields. Then configure the display formatter of the image field in the bean block to display wrapped in the link (Image Link Formatter).
On top of that, add Field Collection and Entity Translation to have multiple images with links, in multiple languages, which pretty much rounds this up (very flexible and granular configuration of blocks with image links).
Installation and configuration:
1 - Download the module and simply copy it into your contributed modules folder:
[for example, your_drupal_path/sites/all/modules] and enable it from the modules administration/management page.
More information at: Installing contributed modules (Drupal 7)
2 - Configuration:
After successful installation, browse to the "Manage Display" settings page, for the entity (Node content type, for example) with an image and a link field, to configure the formatter (See attached screenshot).
For example: the page content type:
Home » Administration » Structure » Content types » Page » Manage display
a. Entity translation support:
For field translation to work, both fields translation need to be enabled. If only one of the two fields has translation enabled (and not the other), the formatter will not work and the link will not be displayed properly on the image.
Both image and link fields have to be translation enabled.
b. Link field settings:
Link field configuration settings will all be applied to the link wrapping the image.
For example, if the field is configured to allow user to select to open the link URL in a new window, then this setting will also be applied to the image link.
c. Multiple values:
Multiple field instances will work based on field delta.
For example: value 0 of field link will be wrapped around value 0 of field image. Value 1 of field link will be wrapped around value 1 of field image .... and so forth.
There are already plans to open a 2.x branch which should be based on the Field Formatter Settings (See: #945524: Field formatter settings hooks in core) module to allow altering core Image module formatter.
This would reduce the amount of necessary code and increase compatibility with core module, but add a new dependency to Field formatter settings.
Contributions are welcome!!
Feel free to follow up in the issue queue for any contributions, bug reports, feature requests.
Tests, feedback or comments in general are highly appreciated.
- Maintenance status: Actively maintained
- Development status: Under active development
- Module categories: Content, Content Construction Kit (CCK), Content Display, Fields, Theme Enhancements
- Reported installs: 854 sites currently report using this module. View usage statistics.
- Downloads: 1,441
- Last modified: April 14, 2013