If I insert a media asset image into CKEditor, I cannot find a way to add a link to it. I was hoping I could highlight the image, click the link icon in CKEditor, fill in the info and then have an image that was linked. But that doesn't work for me.

I also tried to edit the the source and put an href tag around the media asset code (tag?). But, when I do that and go back to WYSIWYG mode the href tag has been stripped.

How does one add a link to an image and if there is no way can one be added?

Comments

Anonymous’s picture

I have the same problem but with media module.

xadag’s picture

Hi,

I've got the same problem, it's impossible to have a simple a href link between an asset token.

Do anyone has an idea about that problem ?

Thanks!

indigoxela’s picture

Issue summary: View changes

Hi all,
an asset is an entity not simply an image or a file, so you need a different approach.
(This is not a bug but some sort of misconception.)

Anyway, there is an easy way to solve the problem without coding.

Have a look at https://drupal.org/project/linked_field module.
(It depends on field_formatter_settings.)

If you want to allow your users to add custom urls, you will need to add a "link" or "url" field to the image asset (/admin/structure/assets/manage/image).
Then you can choose the according token in the asset's display settings.

mattew’s picture

@indigoxela Tell me if I'm wrong, but for the moment Asset do not support link or url field types in "override asset" form. It means that the link will be a part of the Asset, ike "hard coded" into it. This is not logic.

I think this feature should be provided by a separated module, providing a CKeditor custom plugin to write the link attributes (url and target) inside the asset tag, then alter the [asset] text filter to put the link on the image, or at least add a JS code to add the link on the whole Asset.

It sounds complicate, but it is the way it should works. Links attributes should not be stored using fields, because it should not be a property of the Asset, this feature should be related to the WYSIWYG environment, not to the Asset entity.

mattew’s picture

Here is a related issue with a patch for the link_field field type support, to be able to override its value.

indigoxela’s picture

To my opinion a different link should be a different asset, otherwise things could get pretty chaotic. But I'm not the one to decide that.
Possibly other people would appreciate your suggested feature.

mattew’s picture

We did not managed to use the "target" native option of the link_field in Override Asset form, so we enhance list_boolean field to support in this form and create a separated field for that feature, see related issue.