I have been pulling my hair out over the last few days, trying to find a way to combine a custom link field with an image field, to no avail. I could accomplish this with one image field value and one link field value through Views, but I can't do it with more than one value for each. (I have a content type with 3 image field values per node) At any rate, relying on Views for such a basic function seems unwieldy. Using the field collection module I can almost get there, but I still need to create a custom template for my content type in order to go all the way. For a variety of reasons, this is not a great solution. This particular site requires numerous content types and the ability to add more without necessarily having access to a Drupal developer. Any time a developer is required for basic functionality like this, it represents an extra cost to an entity that chooses Drupal as its CMS. I could also completely give up on image fields and try to accomplish this with a WYSIWYG editor and many lines of CSS, but again that's a long painful row to hoe just to wrap a link around an image.

There was a Link Image Field module but it has not been released for Drupal 7, and it works with a "link image" field instead of the existing image field. (The D7 release of this module seems to mired in red tape at the moment, maybe someone can expedite it)

http://drupal.org/node/949588

In my opinion, this should be part of core and it should work with image fields.

This seems like a fairly simple need: the ability to link an image to any URL we want. Presently, image field link options include "content" (the current node) the file itself, or "nothing." These are also managed through field display settings for all nodes of a content type (as opposed to being set with each image field value as it is uploaded on an individual node).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jenyum’s picture

FileSize
41.09 KB

Below is a screenshot of the out of the box image upload interface in Wordpress. This has become what the average user expects from a CMS. I love Drupal but it is behind in this regard.

Wordpress Image Handling

pfrenssen’s picture

Status: Active » Fixed
jenyum’s picture

Status: Fixed » Active

Yes, I noted that in my post. It's not available for Drupal 7, does not have a current maintainer, and introduces another field type rather than working on the existing image field. At any rate, this really should be in core. Please do not mark this as fixed.

pfrenssen’s picture

I don't think this is something that belongs in core. The philosophy of Drupal is quite different from Wordpress. If you need additional flexibility in Drupal, then this is usually provided by contributed modules. Having images link to external websites is not universally useful for all websites, so this is better off as a contributed module. This gives everyone the choice of using it or not. This is why the Link Image Field module exists.

Link Image Field has already been ported to D7 over a year ago. There is also an alternative version available which uses the core Image field, so your needs might already be covered. It might be hard to find these D7 versions because (as you know) the module is currently unmaintained and these downloads have not yet been made available on the project page. For the moment development is happening in a number of sandboxes until a new maintainer is appointed.

Here are some useful resources:

  • Initial D7 port of Link Image Field - this is the initial port by skilip as a zip file. It uses its own field, just like the D6 version.
  • Current 'stable' D7 sandbox - this is maintained by James Benison, based on the port by skilip. The latest version has additional bugfixes and is considered as stable. This is the most widely used D7 version.
  • Improved D7 version - this has been made by Droath based on James' sandbox. It uses a field formatter for the image field in core instead of defining an additional field type. This is probably the best implementation but it has not yet been widely tested.
kingfisher64’s picture

I'm completely with you jenyum. I simply want to make an field image linkable so that it loads up an external site on click.

There can be such a thing as a too modular approach. This is basic functionality that is of common use. I think the drupal leaders need to consider what other users coming from other systems expect. A developer friend of mine was put off drupal by simply not understanding this approach. He thought it was too modular.

I realise there's a balance to be found here - that needs to be taken on a request by request basis so that core drupal doesn't become bloated. In this specific case I think a image should be linkable out of the box.

samalone’s picture

I just patched my version of Drupal 7.15 to allow image fields to link to any link field created by the link module. The patch adds the names of any link fields to the popup that appears when you click the gear icon next to an image field in the "Manage display" tab of the content type editor. Only the first link in a multiple-value link field is used.

For now I'm submitting this as a "do not test" patch because it's based on 7.15 rather than the latest development branch of Drupal, but if there's interest I will submit a more formal patch.

jenyum’s picture

Version: 7.14 » 7.15

I'm definitely interested! Any other votes?

jwjoshuawalker’s picture

+1

Anonymous’s picture

I would love to see this as well.

DYdave’s picture

Hi guys,

Thanks very much for your comments and feedback on this ticket, it was really a lot of help.

Following up with Add a link option to an image field, your comments and patch from #6, I went ahead and created a new formatter module with project at: #1837170: Image Link Formatter

I would greatly appreciate if I could have some of your feedback on this, since this module is mainly inspired from this particular discussion. It has already been tested, based on this use case:

  1. Configure a field Image
  2. Configure a field Link
  3. [Edit form is based on image and link fields' widgets]
  4. Configure the display formatter to wrap the link around the image

This formatter is based on the Link and Image modules and simply implements a display formatter.
Project's page contains more explanations about how this module would be different from other solutions mentioned above, such as Link Image Field or Custom Formatters, or any other solutions.

Please let me know if you would have any questions on any points/code/aspects mentioned in the project, I would surely be glad to provide more information.

Tests, feedback or comments in general are highly appreciated.

Thanks in advance.

joelpittet’s picture

Version: 7.15 » 8.1.x-dev

Unlikely to make it into 7 or 8.0.x but maybe 8.1.x

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andypost’s picture

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.