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.

Comments

nagy.balint created an issue. See original summary.

nagy.balint’s picture

Issue summary: View changes
nagy.balint’s picture

Status: Active » Needs work
StatusFileSize
new3.15 KB

Here is a patch that does that for the inline version.

Leaving it needs work as the option should not appear when css is selected.

nagy.balint’s picture

Issue summary: View changes
nagy.balint’s picture

Status: Needs work » Needs review
StatusFileSize
new3.21 KB

Okay, 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.

nagy.balint’s picture

StatusFileSize
new5.16 KB

This 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.

garethhallnz’s picture

Hi

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.

garethhallnz’s picture

Status: Needs review » Patch (to be ported)

Thank 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.

zulljin’s picture

Status: Patch (to be ported) » Needs work

Hi nagy.balint, your patch not work correctly with Token - [media:url], I see in DOM:
<a href="url]">Image</a>

nagy.balint’s picture

StatusFileSize
new5.09 KB

Rerolled the patch for latest version.

zulljin’s picture

@nagy.balint, it's still actual?

zulljin’s picture

Status: Needs work » Fixed

Added on 3.0.0.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • zulljin committed 381c8465 on 2.0.x
    Issue #2676114 by nagy.balint, Zulljin: Add link option
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.