Summary: Many people want the ability to create File displays, such as preview images, that link to the content that houses the file. Comment #16 below points out that File Entity Link offers this feature, and it was suggested (comment #21) that given the high level of demand for and expectation that this feature exists (it being analogous to how images are handled), and the simplicity of the module's logic, File Entity Link could become part of File Entity. The File Entity Link maintainer supports this idea (comment #23).

A workaround is also proposed in comment #15

Original post: I have created video upload with CCK to use YouTube video urls. I have then created a view to filter this but unfortunately on the views page all I get is a preview picture which does nothing when you click on the picture. Have I done something wrong here?

Comments

dave reid’s picture

Category: bug » support
Priority: Critical » Normal
Road Kill’s picture

!!!

Road Kill’s picture

Is this module even still maintained it appears that the maintainers of this module do not even bother to reply.This must be the second posted issue and my last issue was posted last year Uninstalling.

arthurf’s picture

@Road Kill please feel free to jump into the issues queues and work on this module. There are many people who have devoted time to this project. While I understand the frustration of not getting an answer the people who work on this project due so out of their own good will. Please be respectful of other people's time and energy.

dave reid’s picture

Yes this module is maintained, but I generally don't respond to people that are rude, abuse the category and priority fields, and expect instant gratification from an open source project.

tsvenson’s picture

@Road Kill: Please click on this link and you will quickly see the activity around this module when it comes to developing it.

Road Kill’s picture

If I have offended anybody of the maintainers of this module then I am sorry but that was not the intention. As maintainer you need to understand that I am very happy to help and test this module but not replying to issues is not conducive to solving issues.

David I am very aware that this project is open source and I do not expect instant gratification. I am one of those people in the Drupal community that thinks a sustainable system should be in place to make Drupal module development more viable. Have you noticed how many modules are sitting on Drupal with no activity for the last 12 months just how sustainable is the current way of doing things.

I would be only too happy to pay a yearly licence fee to use a Drupal Module if such a remuneration system was in place.
My last issue that was submitted October last year and it was only two people who responded and wrote a whole novel about how they are unhappy with the module.

I do appreciate the energy and time that maintainer put into these Drupal modules and although I am not a maintainer of a module I have made my contributions to the Drupal community where I can be it through a patch or just sharing with the new kid on the block.
I understand how busy you guys are and am I very aware of the how busy the issue queue for this module but I also cannot wait four months for an answer.

David is a very busy guy and the time that he has put in to this project is commendable.

aaron’s picture

we were talking about implementing a media bug squad, similar to the views bug squad at http://drupal.org/node/945414, which should help keeping issues from being forgotten about.

I'm going to respond to this specific issue in my next update, so as that it doesn't get confused with this specific response.

aaron’s picture

Project: D7 Media » Media: YouTube
Version: 7.x-2.x-dev » 7.x-1.x-dev
Component: Media field » Documentation

You can usually configure views to link through an image in the field settings for that specific field. It would be helpful to know specifically what behavior you're looking for, as there may be different solutions according to what your trying to do: Do you wanted to click through to the YouTube video page? To the file page on your local system? Or to expand into an embedded video? Or maybe a colorbox?

In any case, none of that is in the realm of the media module, which does nothing to help display a file. I'll move this to the media: YouTube module for now.

aaron’s picture

Status: Active » Postponed (maintainer needs more info)
adamdicarlo’s picture

Title: Preview image not clickable » Unable to link preview image to content
Status: Postponed (maintainer needs more info) » Active

I'm guessing the OP was trying to make the YouTube preview image link to the node (or other entity) the file field is in.

That's what I'm trying to do, and while I can create a file style and set the file style to "Linked [image style]," the link goes to the media (the file entity) -- e.g. the internal path "media/18." I don't see a way to display the YouTube preview image and make it link to content (node) using normal node view modes and file styles.

Is there a way to do this, or would I have to use Views? Or write a custom file style or field formatter or... I'm not even sure what?

walkero’s picture

I solved this issue by creating a specific node--video.tpl.php where I added the following code

<?php if (!$page): ?>
    <a href="<?php print $node_url; ?>"><?php 	print render($content['field_video_source']);	?></a>
<?php endif; ?>

and before the rendering of the content I added,

if (!$page)
	hide($content['field_video_source']);  

This way the video preview is linked to the node content.

AFFLemos’s picture

Hi,

Mediasaur and me just solved the same issue i had.

In Views-> Format-> Show -> Try using fields or panel fields.

Now in the field area show your content type: images and direct link to content.

I hope it solves the issue.

dgastudio’s picture

in views, add new field: path and place it it BEFORE your media field.

in your media field, "rewrite results","Rewrite the output of this field " and add something like: [field_video].

alanom’s picture

For me (using stable 7.1 branch), kervi's suggestion didn't work, the only formatters available to me in views link to Media and this <a> markup from the formatter causes Views to reject my custom <a> replacement markup. (using Styles module which may be relevant)

It would be easy - strip HTML tags except <img> then rewrite - but for this Views issue (tags are stripped AFTER rewriting, nullifying the rewrite). It's still pretty easy, but inelegant - I've written up how to do it as an example on comment 4 in that linked issue.

Quick copied-pasted summary (assuming your Youtube field is Field: Video):

  • Have two occurences of the same field - two Field: Videos
  • In the first Field: Video, exclude from view, and set Strip Tags to strip everything non-essential (in this case, we'll keep the <img> but nothing else)
  • In the second Field: Video, set the formatter to whatever requires least processing, because we won't be using it (in this case, probably File URL, or the same as before if it caches), and then write in our markup, wrapping around the replacement token of the first Field: Video field

So the second field, only if not empty, shows the first (stripped) field wrapped in its own (non-stripped) markup.

alauddin’s picture

Ok, here is the solution for linking the preview image to content.

The new media 2.0 by default links everything back to the media/[fid] to make this link back to content.

1) install this module http://drupal.org/project/file_entity_link
2) in manage display select Format > rendered file > select view mode to 'preview' (or whatever you want)
3) now under Structure > File Types
/admin/structure/file-types >> manage file display for your file type (image, video etc)
4) Select 'preview' tab from manage display
5) Select 'youtube preview image'
6) and CHECK BOX to "Link file to referencing entity" now available via the above module.

hope that helps.
Alauddin

ps - this worked for me using Media Youtube, Mediafront (link preview image to node)
and you dont even need the /styles module if you tried that to get the above desired result.

RobW’s picture

@Alauddin, nice helper module. Looking forward to reading people's feedback on it.

@alanomaly, a quick FYI: Styles module is no longer recommended with any of the Media modules. Media 2.x does everything Styles did with a simpler UI and less moving parts, and I think we're going to strip all Styles module code out of Media: Youtube in the 7.x stable release.

alanom’s picture

Slightly off topic comment for RobW - while the documentation surrounding styles, media styles, file styles etc is so variable, out of date and/or patchy, there's an unanswered Drupal Answers question with a bounty on it asking for an explanation or documentation on what the current correct workflow is for setting media styles for media and thumbnails in 7.1 and 7.2, do you think you'd be able to have a crack at answering it sharing the details of the current best, most stable, most future proof media styles workflows for 7.1 and 7.2?

On topic comment - while, as RobW says, styles module isn't looking future proof, in the short term it turns out after some tinkering that the default link wrapping in my earlier comment can be avoided so long as custom, not default, file styles are used, specifying the unlinked version. Not the way to go for future, but might help in the short term for those of us using the stable branch and the old family of modules for production until 2.X is stable.

RobW’s picture

Off topic reply: BAM, answer submitted. Please quality check it in the comments over there -- eventually I'd like to add this to the Media documentation.

RobW’s picture

Marked #1294380: Linking problem in "Manage Display" and #1244958: How to Link Youtube Thumbnail to node and not Media page as duplicates.

Can we consider this fixed with azinck's module File Entity Link? Documentation like comment #16 should also be added to one of the pages being created in #1699066: Revise documentation for Media 2.0; remove deprecated information, include overview and walkthrough examples.

alanom’s picture

Do we have a case for handing this over to File Entity module as a low-priority task to incorporate File Entity Link's feature? That would solve this issue, and others like it, permanently, for all Media- and File Entity- extending modules. Points in favour:

  • File Entity Link is just 88 lines of fairly simple code that works with file entity as it stands. It's not likely to be a major task or complex refactoring/engineering, and since file entities are as a feature capable of being referred to by other entities' fields, if anywhere is to work this feature in, File Entity seems the appropriate place.
  • It's a feature many people are used to from images and various other fields, therefore something people are likely to expect from file entities. There's clearly very high demand for this feature - as well as this issue and those two duplicates, here's three more from 20 seconds skimming the Media queue: #1155240: Link thumbnail to node, #1335364: Add a link on a media element, and #1292818: I only need a image link to node!! (the first of these issues has 31 followers - over 60 between the 6 issues, and I suspect there are more dupes out there across the media family)
  • File Entity Link has not been updated since 2011 (potentially not under active development, at risk of breaking on future changes to File Entity core). A little effort while the two fit neatly together could avoid a lot of more difficult effort following divergence further down the line.

Edit: two more dupes... #1189838: Display teaser: Now links to media instead of node, #1617252: Can an inserted image be linked back to its node?

RobW’s picture

Title: Unable to link preview image to content » Integrate File Entity Link's features into File Entity?
Project: Media: YouTube » File Entity Link
Component: Documentation » Code
Priority: Normal » Major

Moving this to File Entity Link's queue for review of #21. There is certainly a case for integrating this into file entity, but we should get azinck's thoughts on it first. I'd be happy to do some of the work if it's approved by azinck and the File Entity maintainers.

azinck’s picture

I'm very happy to have this functionality subsumed by File Entity. I would greatly prefer that, in fact :). If the File Entity folks want to take the approach I've done here to solve the problem then it would be trivial for them to integrate it. If they feel there's a better approach I'm happy to chat it over.

alanom’s picture

Project: File Entity Link » File Entity (fieldable files)
Version: 7.x-1.x-dev » 7.x-2.x-dev
Category: support » feature

Great! So I guess we pass this over to File Entity for their approval as a feature request for which most of the work has been done already by azinck in File Entity Link?

(unless anyone knows a more efficient way to keep this moving forward?)

I've added a summary to the original issue so people don't have to wade through too much to see what this is about.

azinck’s picture

If the File Entity folks are happy with this approach then I can roll a patch.

peteruithoven’s picture

I would usually fix this by using the fields display mode, adding a path (absolute) and rewriting the results of the media field by creating a link out of it and then filling in [path] as link. But since the 7.x-2.x release this doesn't seem to work anymore.
The File Entity Link module does seem to work.
I don't want to be rude, but I hope I can get some attention to this issue again, since azinck asked his question in september.

RedRat’s picture

If the File Entity folks are happy with this approach then I can roll a patch.

I can test your patch on my development installation.

dave reid’s picture

Priority: Major » Normal

I'm not sure we can support this functionality with rendered files, which can have complex output. I may need to look at the code again, but last I had checked, I didn't get that immediate "yes we should be supporting this natively" feeling based on the code.

azinck’s picture

Frankly, I think File Entity Link's functionality is pretty much obviated by http://drupal.org/project/linked_field

devin carlson’s picture

Status: Active » Fixed

File entity 7.x-2.0-alpha1 now allows you to use the Image formatter provided by the core Image module (without losing alt + title text). The core Image formatter allows you to link an image to its parent content.

I'm making this as fixed since, in my experience, linking images to content is the primary use case for this functionality and I don't believe that File entity should try to wrap formatter output in links because that can easily lead to invalid markup (as is often seen with contextual links).

Ravenight’s picture

Status: Fixed » Needs work

I can't seem to make this function as you described. I am re-opening this to get a solid explanation on how to make this work.

I have alpha1 running using Views to output a grid of content nodes.
The Content node has a media field on it. I display this field in views with the "media" formatter (only choice available) and select the "teaser" view mode.

In File Entity, under "teaser" view mode and manage display I have selected "image" under "enabled displays" and in the image settings under the pull down "Link to image:" there are three options:

1: nothing - works as expected
2: content - links to the file entity's page [/file/FILE_NAME.PNG] - not the referencing node the image is attached to
3: file - links directly to the file [/sites/default/files/FILE_NAME.png]- as expected

How do I link the image to the referencing node that I am calling in views?

I have already tried re-writing the file_entity field as a link with the "node/[nid]" field. This puts an empty tag with the proper href on the page but it does not wrap around the file_entity fields.

I also tried using file_entity_link but that also did not work, nor do anything at all that I could see.

I have ended up using linked_field to make this work. It would be nice if I could do this without another module but for now, with this extra helper, I am able to make this work using DisplaySuite, and Views where I render the content in its own DS view mode with the linked field active and a token to the "node/[nid]" on the media field.

Ravenight’s picture

Issue summary: View changes

No need to read through a lot of unrelated comments including an ugly argument to see what this issue is really about

tchopshop’s picture

I'm in the same boat as Ravenight, I made my media file image work finally with linked_field in views and thought I was done.

However, I have now incorporated the Picture module into the mix. Picture module does not work with linked_field in views for some reason. I guess I need to write on the Picture issue queue, but am also posting here, because I'm not sure which one ultimately needs to be patched.

If only the views option worked!

Update: Although it didn't work earlier, with Picture module File Entity Link is working for me.

kiwad’s picture

Issue summary: View changes
Status: Needs work » Active

Seems there no active patch in this issue so marking back to active instead of need works, but maybe it should also be categorize in support request/documentation ?

Maybe worth mentionning that per comment #15 almost got it working.
I'm only stucked with my file title... but I guess I could get rid of it by rewriting my templates...

awm’s picture

I found the best way to do this is to create your custom file formatter. For example for a project of mine that uses youtube and brightcove video integration I did this

<?php

// Create a custom formatter
/**
 * Implements hook_file_formatter_FORMATTER_info().
 */
function CUSTOM_MOSULE_video_file_formatter_info() {

  $formatters['CUSTOM_MOSULE_video_brightcove_youtube_video_image'] = array(
    'label' => t('Youtube/Brightcove Video Preview Linked Image'),
    'file types' => array('video'),
    'default settings' => array(
      'image_style' => 'medium',
    ),
    'view callback' => 'CUSTOM_MOSULE_video_video_file_formatter_image_view',
    'settings callback' => 'CUSTOM_MOSULE_video_file_formatter_image_settings',
  );

  return $formatters;
}
// add the settings for it. (may not be necessary)
function CUSTOM_MOSULE_video_file_formatter_image_settings($form, &$form_state, $settings) {
  $element['image_style'] = array(
    '#title' => t('Image style'),
    '#type' => 'select',
    '#options' => image_style_options(FALSE),
    '#default_value' => $settings['image_style'],
    '#empty_option' => t('None (original image)'),
  );
  return $element;
}

/**
 * Implements hook_file_formatter_FORMATTER_view().
 *
 * Link the preview image to the attaching entity of the file.
 */
function CUSTOM_MOSULE_video_video_file_formatter_image_view($file, $display, $langcode) {
  // Check if the file's referncing entity
  if (property_exists($file, "referencing_entity")) {
    $referencing_entity = $file->referencing_entity;
    $scheme = file_uri_scheme($file->uri);
    if ($scheme == 'youtube') {
      $element = media_youtube_file_formatter_image_view($file, $display, $langcode);
    }
    elseif ($scheme == 'brightcove'){
      $element = brightcove_media_file_formatter_image_view($file, $display, $langcode);
    }
    if (!empty($element)) {
      $element['#prefix'] = "<a href=" . url('node/' . $referencing_entity->nid) . ">";
      $element['#suffix'] = "</a>";
      return $element;
    }
  }
 
}