Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello! I've made it so that thumbnails are shown on node teasers. Is it possible to make the thumbnail link to the node? If not, that would be a great feature for this module.
Solutions and Work-arounds
I have not tested, but here is a summary of suggestions from the comments below.
- @azink wrote the File Entity Link module after finding no solution here. See #20 below. By design, it works with File fields, not the deprecated Multimedia asset field type. Several comments report that the module works well (#27, #36, #40).
- If you are using Views with a Fields display (not Nodes) then select the "Strip HTML" option and enter
<img>
, then use the "Output this field as a link" option. See #29, #31. - Edit the
node.tpl.php
file in your theme directory. See #10.
In #2 and #17, the maintainers suggested they might accept a patch. In #28, one of the maintainers closed the issues, considering the File Entity Link module a solution to the issue.
Comment | File | Size | Author |
---|---|---|---|
#34 | media-link.patch | 1.35 KB | Jody Lynn |
Comments
Comment #1
Mèche CreditAttribution: Mèche commentedSubscribe
Comment #2
effulgentsia CreditAttribution: effulgentsia commentedNot currently possible with Media module alone, but could be done with a smallish custom module that either defines its own formatter for the media field type, or extends the 'media' formatter.
If someone wants to submit a patch on this issue that adds a 'Link media to' setting to the 'media' formatter, similar to how core's Image module does for the 'image' formatter, it would be great, and I'm definitely open to committing something like that. However, note that this is more challenging for media, since the corresponding file entity being rendered might not be an image, and might also display fields, and there's issues with adding anchor tags around block-level HTML.
Comment #3
Toxid CreditAttribution: Toxid commentedI solved this in the theme node.tpl file by running the image through the l() function to generate a link to the node.
Comment #4
csunny CreditAttribution: csunny commentedSubscribe
Comment #5
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedSubscribe.
Comment #6
aaron CreditAttribution: aaron commentedi currently also get around the issue by using the 'rewrite field' option when adding it in views.
an issue would be context though -- for instance, when used in wysiwyg.
Comment #7
Shadlington CreditAttribution: Shadlington commentedSubbing.
Comment #8
CrashNet CreditAttribution: CrashNet commentedCould you provide more detail on your solution Toxid?
Comment #9
parasolx CreditAttribution: parasolx commentedjust wanna to ask, how did you put your thumbnails? through media browser or field?
Comment #10
Toxid CreditAttribution: Toxid commentedI used bartik template for this, and edited node.tpl.
In my example, field_image is the name of my field. I also have youtube thumbnails, so if you want that you simply duplicate the if statemens and replace field_image with the youtube field name.
My method makes the image display last, since render($content) contains the rest of the information. Use the hide function to hide the fields you want below the image, and render them after the image link. If you need to see the fields in $content, just use print_r($content).
Comment #11
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedThank you.
Just a tip: You don't have do check variables using isset when passing them to render and hide.
Comment #12
Toxid CreditAttribution: Toxid commentedThanks, that's good to know. Drupal usually gives me a message saying "variable index not defined" when I don't use isset. But perhaps that's only a setting that needs to be changed.
Comment #13
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedThis is off topic here, but
render
andhide
are special, because they take references:function
render
(&
$element) { ... }
Comment #14
minneapolisdan CreditAttribution: minneapolisdan commentedsubscribing
Comment #15
energee CreditAttribution: energee commentedsubscribing, #10 did not work
Comment #16
Toxid CreditAttribution: Toxid commented@ energee, You must replace parts of the fields in code to correspond your nodetypes fields. If you just copy and paste then it won't work.
Comment #17
JacobSingh CreditAttribution: JacobSingh commentedThis will not happen in 1.x and *may* be accepted to 2.x if someone writes a patch for it, but more likely it should live as separate contributed module.
Comment #18
energee CreditAttribution: energee commented@Toxid, I was aware of that, however didn't see any success with this, ended up working around this with css and html to float an anchor over the video. I'm sure this will be corrected in the module soon.
Comment #19
liquidcms CreditAttribution: liquidcms commentedi used a PHP views field with this as the output:
ugly, but worked... this should be a formatter within the media module.
Comment #20
azinck CreditAttribution: azinck commentedI just created a really simple project called File Entity Link that meets my needs. As I mention on the project page:
It's simple and I'm not sure I've chosen the best architecture for it but I really wanted to be able to link just the file (not other fields on the file entity) so this is what I went with. I hope it helps some folks.
Comment #21
idflood CreditAttribution: idflood commentedI would add that another workaround is to use the display suite module (http://drupal.org/project/ds).Comment #22
azinck CreditAttribution: azinck commented@idflood:
While I've used Display Suite I'm not an expert with it. How would you propose to solve this with DS? Would you add a custom field?
Comment #23
idflood CreditAttribution: idflood commentedMy bad, it was not the display suite module that was displaying that... it's the field_slideshow module. See possible options:
http://cl.ly/3N0a2a420n0L2O0S232a
Comment #24
bpeicher CreditAttribution: bpeicher commentedThe ability to link a thumbnail to a node would make this module much more useable. It seems strange that the rewrite output function in the Views module works on everything but a media field.
Comment #25
azinck CreditAttribution: azinck commentedbpeicher: did you try File Entity Link or Field Slideshow? With a little configuration either of those two modules should be able to solve your problem.
Comment #26
dlsmore CreditAttribution: dlsmore commentedThe File Entity Link and Field Slideshow solutions seem to work with images, but does anyone have an idea of how to link video (youtube, vimeo) thumbnails to the node?
Comment #27
dlsmore CreditAttribution: dlsmore commentedAh, answered my own question. So I upgrade to the latest dev version of Media and File Entity, and had File Entity Link installed too. Then you have to use a field type of "file" instead of multimedia asset. File Entity Link then does the linking of the thumbnail.
Comment #28
Devin Carlson CreditAttribution: Devin Carlson commentedAs per #20 and #25, the File Entity Link module can be used to accomplish the functionality outlined in the original issue. Confirmation was given that the module works in #27.
Comment #29
Musicious CreditAttribution: Musicious commentedHi Guys, I solved this without the need for other modules...
In views, in the fields settings.
Select strip html, and then put "< i m g >" (without spaces) into the ignore tags field form.
Then select rewrite as URL, as you would normally.
Have a cup of tea.
Will.
Comment #30
cpelham CreditAttribution: cpelham commented@Musicious What did you re-write the URL to be (to get it to link to the node that the img file field is attached to)?
Comment #31
Musicious CreditAttribution: Musicious commented@cpelham I have forgotten.
Right went and checked...
Yeah just select 'Output this field as a link'
then put this in link path
node/[nid]
( I loaded nid as a field , above this field, then selected the do not display option for that field, making nid a token)
Hope that helped.
Comment #32
cpelham CreditAttribution: cpelham commentedMost of the media formatters seem to hardwire the output as a link to the media. so selecting "output this field as a link" just wrapped a second link tag around the hardwired one. But selecting the formatter "media" and a size like "medium" produced an image without a link tag wrapped around it. so then I could successfully do what you suggested. Thanks!
Comment #33
Musicious CreditAttribution: Musicious commentedI think I achieved that when Selected "strip html", and then put "< i m g >" (without spaces) into the ignore tags field form.
So that striped all the html apart from the image, then made the image the link I wanted.
Well glad you got it sorted.
Comment #34
Jody LynnThe file_entity_link module does not work for multimedia fields. It also seems strange to add an extra module just to get a link.
This patch adds the option for links in the media field.
Comment #36
altrugon CreditAttribution: altrugon commentedazink got the solution on #20 >> http://drupal.org/project/file_entity_link
Comment #37
Jody LynnRight, but like I said it doesn't work for multimedia fields. And it should be included as an option in media module, not as a separate module.
Comment #38
azinck CreditAttribution: azinck commentedJody Lynn: multimedia fields have been deprecated.
Comment #39
samwillc CreditAttribution: samwillc commentedThe solution at #29 by Musicious is the way I am trying to do it. Adding another module just for this is insane, this is a totally standard thing linking a thumbnail to a full node page.
The problem is with Musicious's suggestion is that I get those pesky edit/delete contextual links (which link to the file) showing up in plain text once the div with class "element-invisible" has been stripped.
It was so easy when you just added a field of type 'image' (instead of 'file' using the media module), then views can automagically link to content.
Sam.
Comment #40
samwillc CreditAttribution: samwillc commentedhttp://drupal.org/project/file_entity_link
Works a charm.
Sam.
Comment #41
bxCreative CreditAttribution: bxCreative commented#40 works perfectly!
Comment #42
dwkitchen CreditAttribution: dwkitchen commented#40
Comment #43
Devin Carlson CreditAttribution: Devin Carlson commentedThe file entity link module is a great solution for linking images to their parent entity.
See #1392900: Integrate File Entity Link's features into File Entity? for discussion on incorporating the module into File entity.
Comment #44.0
(not verified) CreditAttribution: commentedAdded summary of proposed solutions.
Comment #45
stijndmd CreditAttribution: stijndmd commented#40 works like a charm.
But shouldn't this be in Media?
Why do we get the option to either link to "file" or "content" when both options link to the file here?
The option "link to content" in Media should by default do what the option given by #40 does, IMO.
Comment #46
Sagar Ramgade CreditAttribution: Sagar Ramgade as a volunteer commented+1 for this, I think this should be part of the Media module.
Comment #47
karlkablisk CreditAttribution: karlkablisk commentedSo many years of discussion since this issue and is still a problem :/
I was struggling with this and after reading a lot of the multiple discussions I came up with this method for VIEWS using media with youtube.
1. Get this and install this module
http://drupal.org/project/file_entity_link
2. Go to file settings for your display
admin/structure/file-types/manage/video/file-display
and choose the one you want to use (like preview for example) and use the youtube thumbnail.
Check the box at the bottom so the link goes to the content and not the file.
3. Make your view as usual to use the youtube preview
4. Go to rewrite settings and choose STRIP HTML
Be sure to put a few exceptions I put these
< img > < div > < ul >
(Without the spaces! The < a > link default in this is what makes the link not work so you are using this feature to strip it out)
5. Your content should display on the page with the title above it. The link to the content should work, so now you just need to get rid of the text, but it doesn't have any styling. So I suggest CSS
.file-video-youtube {
font-size: 0px;
}
This gets rid of the text and the linked image should work. Not the best solution but it only requires 1 module. I think the module makes fields work by default so views is the hard one to get a workaround for.