Problem/Motivation
Sometimes this module is used to make the design easier to implement, and sometimes it is used to make an image non draggable in the browser.
However in case it is used in a view as an image for an item, we might want that image to be clickable to lead us to the node page.
And defining JS just for that behaviour does not seem to be a nice way of doing it.
Proposed resolution
The formatter could offer a new option. "Link to content", which if checked would wrap the div with the background with an <a> </a> tag. Since HTML 5 this is allowed.
Is there any interest in such a feature?
For inline this solution would work fine as it simply outputs a div in a tpl file, so we can add an <a> in case of the new option is checked.
Likely we cant do anything with the css version as it only outputs the css then.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | add-link-to-content-2676114-10.patch | 5.09 KB | nagy.balint |
| #6 | add-link-to-content-2676114-6.patch | 5.16 KB | nagy.balint |
| #5 | add-link-to-content-2676114-5.patch | 3.21 KB | nagy.balint |
| #3 | add-link-to-content-2676114-3.patch | 3.15 KB | nagy.balint |
Comments
Comment #2
nagy.balint commentedComment #3
nagy.balint commentedHere is a patch that does that for the inline version.
Leaving it needs work as the option should not appear when css is selected.
Comment #4
nagy.balint commentedComment #5
nagy.balint commentedOkay, so since this only has to work for the inline version, as the css will not output any div, then I moved code around a bit, and added a states definition to hide the checkbox in case the css type is selected.
Then this is ready for review.
Comment #6
nagy.balint commentedThis patch will add a custom option, so any link can be defined to be used instead of the content's link. Tokens are allowed, and a browser is added if the Token module is enabled.
Usecase could be if the link is defined in the entity itself, or if its dynamically constructed.
Comment #7
garethhallnz commentedHi
Thank you very much for your work.
It's probably not with doing any work here as we are in the process of merging this with Background Images Formatter module.
The progress is documented here Merge background_image_formatter into bg_image_formatter
So far I have only merged the 7.x version and will be looking at the 8.x one next.
Comment #8
garethhallnz commentedThank you for the patch I really appreciate it.
However since the project is obsolete and being merged with: https://www.drupal.org/project/bg_image_formatter there is no point to keep working on this code base.
Comment #9
zulljin commentedHi nagy.balint, your patch not work correctly with Token - [media:url], I see in DOM:
<a href="url]">Image</a>Comment #10
nagy.balint commentedRerolled the patch for latest version.
Comment #11
zulljin commented@nagy.balint, it's still actual?
Comment #12
zulljin commentedAdded on 3.0.0.