I'm not familiar enough with media module and its various complexities to even begin to offer a patch.

media modules 7.x-2.0-unstable6+3-dev

Files: 
CommentFileSizeAuthor
#75 media-7.x-2.0-unstable7-quickselectfix.patch1.85 KBrambazambi
PASSED: [[SimpleTest]]: [MySQL] 5 pass(es).
[ View ]
#64 1743040-64-2.0-unstable7.patch2.47 KBdalin
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1743040-64-2.0-unstable7.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#55 media-you_have_not_select_anything-1743040-15.patch2.42 KBParisLiakos
PASSED: [[SimpleTest]]: [MySQL] 56 pass(es).
[ View ]
#49 Screenshot_1_25_13_1_54_PM.png105.68 KBarthurf
#48 modal.jpg45.21 KBaaron
#46 1881152_insert.2.diff2.02 KBarthurf
PASSED: [[SimpleTest]]: [MySQL] 5 pass(es).
[ View ]
#41 1881152_insert.1.diff1.86 KBarthurf
PASSED: [[SimpleTest]]: [MySQL] 5 pass(es).
[ View ]
#38 1881152_insert.diff1.42 KBarthurf
PASSED: [[SimpleTest]]: [MySQL] 5 pass(es).
[ View ]
#6 application-bundle-preview-view-mode.png70.62 KBstevector
#3 media-media_browser-preview_javascript_incompatibility-1743040.patch802 bytesaaronbauman
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
Safari.png251.07 KBaaronbauman

Comments

Component:Code» Media Browser

adding: it's not clear from the OP, but I can select image files (.jpg, .png, .gif) files a-ok

Status:Active» Needs review
StatusFileSize
new802 bytes
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

OK, I did found the culprit.
Previews for non-image files contain links (ie. <a> tags).
Then the media browser adds a wrapper <a> tag to the preview.
Nested <a> tags cause the javascript to fail.

This patch fixes the media browser preview by stripping various html tags, including <a>

Status:Needs review» Needs work

This breaks media players being used in the preview as well... for example, using a MediaFront player as the preview style will not work with this patch.

I would recommend changing the JavaScript to find the correct link rather than stripping all HTML tags other than the expected ones...

So, having a media player inside an <a> tag is legal HTML?
Seems like that's asking for problems too.

Status:Needs work» Closed (won't fix)
StatusFileSize
new70.62 KB

Each file in the browser is rendered with the "media_preview" view mode. The a tags should be excluded there. I ran into this same problem and changed the settings at /admin/structure/file-types/manage/application/file-display/media_preview

I recommend using "Large filetype icon" instead of "Generic file."

Status:Closed (won't fix)» Active

The patch on #3 worked fine for me and solved my problem. Why this is not included on the actual 7.x-2.x-dev release?

If media ships with a view mode configuration that causes a UX bug, that's a bug.
Perhaps the patch in #3 is a little too brute force.

A more appropriate patch would be for media_preview view mode configuration to be fixed.

@#8 exactly.
We need a patch that does what is described @#6

The issue is that when you leave everything at the defaults, the preview is rendered with the file_link theme. This is set by file entity. Media either needs to check for that theme and change it to something else, or provide configuration for the preview view mode for every file type.

In addition to shipping with broken default configuration, allowing an administrator to break the media selector view by reconfiguring a file display is a poor user experience.

My patch from #3 is a sub-optimal approach, but does the job.

Here are some ideas for better approaches, if anyone else wants to take a stab:
* modify the media selector views plugin to use core views fields instead of its own display plugin
* modify the media selector views plugin to render files in a way that definitely won't break the javascript (ie. not dependent on admin configuration)
* use a post-render hook (or other possible hook) or javascript to fix the invalid DOM elements

I have got the same error. But i think its another reason. The field allows pdf files only, but it is not possible to submit an selected pdf. Only Images can be submitted. So i took a look in the media browser settings and found {"types":{"image":"image"}. I think there should be something like {"types":{"document":"document"}.
?

I didn't had a 'preview' viewmode. After creating this viewmode everything works well.
Without using the patch.

Like mentioned on comment on #3, this seems to be caused by anchor tags around non-image thumbnails.

I have managed to fix this by configuring the 'Preview' mode of the file display for the offending file type (this is Application on 7.x-2.0-unstable6), and unchecking all of the 'Enabled displays'. It was initially configured to display 'Generic file', which displayed the preview with the anchor tags around. I may have selected that display manually, can't remember if it was set as such out of the box.

I found this thread after experiencing the same issue: using Media Browser to select PDF files (which happens to be in a Field Collection) when creating/editing a node.

Thanks to tips from Comments #3, #6 and #14, I fixed this on my site by setting the config here:
/admin/structure/file-types/manage/document/file-display/preview
to Large Filetype Icon.

Unlike victoriachan's experience, unchecking all "Enabled Displays" didn't work (that appears to be the default). And like victoriachan, I don't recall having made any config changes here, but probably an oversight on my part.

In any case, I concur with comments that the out-of-the-box functionality is confusing, but I think that better documentation may be a more elegant solution than trying to code for every use case.

This is essentially a duplicate of #1792738: Allow custom file view modes for WYSIWYG display.

There's two solutions here:

  • Assume/force the preview view mode to output an image.
  • Do not use links at all; every file could be wrapped in a <div> which holds the file's unique ID.

Just to stuff this info somewhere:

Using the latest releases (unstable-7) for both media & file entity:

I experienced the "You have not selected anything!" behaviour (as well as image previews in the media popup all being the default file icon enlarged). I tried setting various enabled displays on the file display as indicated above and tried unsetting them as indicated above, nothing worked, then I saw an error in js (I didn't copy it, apologies) indicating a view mode being undefined for wysiwyg-media.js and thought I wonder if I need to go and save my WYSIWYG settings and text formats again to reset some variables...so I did that and boom I could embed images...so I went back to my file display settings for the image file type and strangely enough all the new view modes had disappeared! I don't know if this will introduce some issues soon or what but I assume they were added by the update for good reason. and a save on either WYSIWYG or Text Format settings wiped them out.

EDIT:

Much of the crazy behaviour I experienced with file entity & media was due to some updates not applying but failing silently in drush, much ado, much borkedness and rolling back DBs later, I moved up to the latest dev release for both, and added the large file icon to the default file display and it works again.

Cheers,
JP

#3 seemed to have done the trick.

Setting the preview view mode to 'Large filetype icon' at admin/structure/file-types/manage/document/file-display/preview worked for me.

@#19 - worked for me as well

#6 works.
@stevector thanks.

Medial module itself should care about this when installing.

I ran into this problem after upgrading a site from unstable3+38-dev to unstable7 - it was not physically possible to select any of the files. I tried changing the preview display mode for documents but it made no difference, but Aaron's patch from #3 resolved the problem for me.

I concur with #22

There's a comment in the code that indicates that "Large filetype icon" is offered only for legacy support, which implies to me that it's deprecated. Is this something that would make it a poor choice for this solution?

where is that comment?

Lines 31-40 of media/includes/media.fields.inc

/**
* Implements hook_field_formatter_info().
*
* Provides legacy support for the "Large filetype icon" file field formatter.
* This was originally used when media entities contained file fields. The
* current file entity architecture no longer needs this, but people may
* have used this formatter for other file fields on their website.
*
* @todo Some day, remove this.
*/

nice...i guess we should rethink the approaches here..we also need a proper issue summary

When using the patch from 3, "URL to file" doesn't seem to insert anything into the WYSIWYG either.

Issue summary: The "You have not selected anything" error appears when inserting non-images via file browser. The patch in #3 is a messy workaround that, while effective, may break other things. It works by stripping tags. Only allowing "Large Filetype Icon" also gets around this problem, sort of, but it's a deprecated view mode.

The large filetype icon is not being deprecated. I think the context of the comment in #26 is related to the Media field type which is in fact deprecated.

Hi, I am having this error, also for image files. After disabling media 1.0 and setting up media 2, the media browser only shows filetype icons instead of thumbnails, then also this error if you try to select one of them. This occurs in unstable7, sorry if it has been fixed in dev

Same situation as @DamienMcKenna at #22 (update media), and #3 fixes it. In fact every time i update media i have to patch again.

both #3 and #9 works for me

What exactly is it that gets broken by using the patch in #3?

The patch in #3 is a hack that does not address the core issue.

The core issue, from what I gather, is that the View that ships with Media and provides the "View Library" display defaults to using a file rendering method that's usually incompatible with Media Browser's javascript. Stripping the HTML from the rendered file is a brittle bandaid to address this particular symptom.

A proper fix would be for Media module to either ship a file display mode that worked with its display, OR provide a formatter/widget that rendered the file without causing javascript issues.

I agree. The workarounds mentioned here puts a bandage on one problem but, creates usability issues.

What version of file entity are people using who are experiencing this? Is this happening for clean installs (I can't duplicate it with a clean install) or only upgrades? Is it happening from 1.x -> 2.x and unstable X to current dev?

Just trying to gather some information for tracking this down.

@arthurf, i'm always working with a matched pair, and my current version is 2.x-unstable7. I haven't done a fresh, dry install for a while, so I can only confirm that this is a problem during updates.

StatusFileSize
new1.42 KB
PASSED: [[SimpleTest]]: [MySQL] 5 pass(es).
[ View ]

The problem seems to be in template_preprocess_media_views_view_media_browser(). It is wrapping already processed html in a link. This seems to work for images but not for non image content because the label is a link.

I'm not sure if this is the right fix but it seems to work for me. Changed the link to a wrapper div and adjusted the JS to find the wrapper instead of the link.

Status:Active» Needs review

That was exactly what I was thinking. Why use a link if you use javascript anyway? Looks like a good solution to me.

StatusFileSize
new1.86 KB
PASSED: [[SimpleTest]]: [MySQL] 5 pass(es).
[ View ]

Here's a cleaner fix which makes theme_media_thumbnail() for providing the right markup.

Updated from unstable7+4 to unstable7+(latest), then patched from #41. Works like a dream, and finally addresses the root of the issue (RTBC IMO).

Status:Needs review» Active

Tested #41 and works for me.

Status:Active» Needs review

I think we need cross browser testing on this as it's a change to the JS. Can somebody test with chrome/safari/firefox/ie?

would be nice if someone could check it with fangel's media multiselect

StatusFileSize
new2.02 KB
PASSED: [[SimpleTest]]: [MySQL] 5 pass(es).
[ View ]

Here's a reroll with some code cleanup

Status:Needs review» Reviewed & tested by the community

#41 Tested in firefox, chrome, IE 7-10, safari and works in all

StatusFileSize
new45.21 KB

It works great, however, as you can see in the screenshot, the text of pdf files is repeated twice. However, I don't think that's enough to hold up this issue, so I would say this is RTBC, unless someone thinks otherwise.

StatusFileSize
new105.68 KB

Even without the patch I get the duplicate label issue. We could adjust the theme_media_thumbnail() function to not display the label if it isn't an image maybe? Attached screenshot shows a mix of images and other file types in the browser with no patches applied.

The duplicate-label problem would be a nice fix in this patch as well. I've been using CSS to fix the issue in various places, but having the markup consistent with theme_media_thumbnail would be nice so the duplicate labeling is fixed "everywhere".

Patch at #49 fixes the selection problem, issue mentioned at #51 fixes the duplicate title problem. Pleased.

#46 patch fixes the problem for me. Tested in Google Chrome and Firefox for Mac.

I'm using media and file entity 2.x-dev on Google Chrome Mac.

@rootatwc - I also tested the patch with fangel's media multiselect module. I'm seeing some strange behavior on field that uses fangels media multiselect browser:

1. On a file field set to unlimited values: In the media browser library I'm able to select files one at a time. Am I supposed to be able to select multiple?
2. on the media browser upload tab I am able to upload multiple files with plupload module with no problems.
3. In the media browser library tab: When I try to select one item and hit submit, it loads two media items in the field.

Note: When using just the patch in #46 without the Fangels media multiselect I do not see the problem listed in #3.

@mpgeek, #49 doesn't contain a patch.

Status:Reviewed & tested by the community» Needs work

Thanks gmclelland for testing..yes seems media_multiselect does not work with this patch.
I dont want to break multiselect ability from media browser again
checking now

Status:Needs work» Needs review
StatusFileSize
new2.42 KB
PASSED: [[SimpleTest]]: [MySQL] 56 pass(es).
[ View ]

I was able to restore the multiple selection inside the browser..but after selecting multiple items and submitting the form..i only get one value in the field..but the same behavior applies before the patch...so we already managed to break this, somehow...i guess it would be nice to have some feedback from fangel, if someone can ping him

Someone called? :) I'll read through the issue, and take a look at the patch tonight so we can get this working.

heh that was fast:) thanks

I can't get it to fail. That is, everything seems to work for me (after I got my browser to reload the js file). And my review of the patch can't see why it should fail either.

I always start my test with the browser test-bed (media/browser/testbed), plug in the following for options "{multiselect: true}" and hit "Launch Media Browser". Then you should be able to verify that it returns a list of all items (it can be hard to decipher the huge json return, but it's possible).

And my multiselect widget (despite what people might think) relays 100% on the JS in Media. There is no JS related to the Media-browser in my module - the only custom JS in the module is what launches the browser. So given that the browser correctly returns all selected entries, the my multiselect module works correctly..

(This was checked with git checkouts of Media + File Entity from yesterday)

So how does this not work for you guys? I'll gladly keep trying to contribute to whatever issues you guys have with the media browser.

@fangel - thanks for looking into this

@rootatwc and @fangel - I just tested the patch in #55 in combination with fangel's module and everything is working correctly with the standard media browser and the multiselect media browser both as a field and when inserted in the WYSIWYG editor(Wysiwyg+CKeditor).

I tested on Google Chrome and Firefox - Mac.

Status:Needs review» Reviewed & tested by the community

ok, then glad it works for you, seems it is one of my other thousands of path i have applied^^

Rootatwc: you can email me a zip of your media module with all patches and I'll gladly try and figure out what's causing multi select to break for you...

Status:Reviewed & tested by the community» Fixed

thanks fangel, if i have a problem with it in somewhere else besides my dev instance i ll open an issue in you sandbox queue.
i went ahead and committed this:) thanks all
http://drupalcode.org/project/media.git/commit/e771336

Status:Fixed» Closed (fixed)

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

StatusFileSize
new2.47 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1743040-64-2.0-unstable7.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Attached is a patch against 2.0-unstable7 if anyone needs.

Status:Closed (fixed)» Reviewed & tested by the community

I have tested the patch in 64, it solves the problem in 2.0-unstable7.

Status:Reviewed & tested by the community» Needs work

The last submitted patch, 1743040-64-2.0-unstable7.patch, failed testing.

Status:Needs work» Closed (fixed)

and its already commited

I applied the patch in #64 but is doesn't fix the problem in 7.x-2.0-unstable7

I also found an issue with using the jQuery Uniform library. It does something to the button that opens the media browser that opens a second (unseen) media browser. This confuses media browser because the 'selected' item gets saved to one window, and the submit button's on the other.

So make sure you don't have Uniform getting in the way. My solution was:

$('a long list of selectors')
        .filter(function(){
          // Don't theme buttons that open the media browser.  Doing so opens a
          // second (unseen) media browser and then you can't select anything.
          return $(this).parents('.field-widget-media-generic').length < 1;
        })
        .once('uniform')
        .uniform();

Just a FYI for folks who come across this late in the game like I did - #3 appears to actually fix the issue of not being able to select documents. #46 and #55 did *not* work for us.

Status:Closed (fixed)» Reviewed & tested by the community

I am re-opening this issue.

This error is still occuring in the latest versions (dev and unstable). The patch posted in #3 is working for us quite well. Since it is working for other users, I suggest we commit patch #3

@cyberschorsch the patch from 3 is pretty aggressive and could cause problems for some formatters.

Can you provide:
* what formatter you're using for the display when the error occurs
* is there anything in your js console
* an example of the html that is output for a single item in the browser

Status:Reviewed & tested by the community» Postponed (maintainer needs more info)

Postponing the issue pending a report from the op.

Title:"You have not selected anything!" error message, when a selection has clearly been madequick patch
Version:7.x-2.x-dev» 7.x-2.0-unstable7
Status:Postponed (maintainer needs more info)» Needs review
StatusFileSize
new1.85 KB
PASSED: [[SimpleTest]]: [MySQL] 5 pass(es).
[ View ]

here is a quick patch for 2.0-unstable7

Title:quick patch"You have not selected anything!" error message, when a selection has clearly been made
Version:7.x-2.0-unstable7» 7.x-2.x-dev

Please don't change the "issue title" field unless you have a reason to, thanks :)

Hello,

when run
patch -p0 --dry-run <1881152_insert.2.diff
patching file includes/media.theme.inc
Hunk #1 FAILED at 82.
1 out of 1 hunk FAILED -- saving rejects to file includes/media.theme.inc.rej
patching file js/plugins/media.views.js
Hunk #1 succeeded at 67 with fuzz 1 (offset -8 lines).
patching file media.views.inc
Hunk #1 succeeded at 77 with fuzz 1 (offset -2 lines).

Any Idea what is wrong with the patch?

In my patch I deleted the a/ and b/ references and have put the patch in the root of the module.
I have also realized that in the patch it is fererrencing the function theme_media_thumbnail($variables) but the original file includes/media.theme.inc only has the function theme_media_admin_thumbnail($variables)

also I can not find this: includes/media.theme.inc.rej

diff --git includes/media.theme.inc includes/media.theme.inc
index f536deb..9e856b3 100644
--- includes/media.theme.inc
+++ includes/media.theme.inc
@@ -82,8 +82,13 @@ function theme_media_thumbnail($variables) {
$element = $variables['element'];
$destination = drupal_get_destination();

- // Wrappers to go around the thumbnail.
- $prefix = '';
+ // Wrappers to go around the thumbnail.
+ $attributes = array(
+ 'title' => $element['#name'],
+ 'class' => 'media-item',
+ 'data-fid' => $element['#file']->fid,
+ );
+ $prefix = '';
$suffix = '';

Priority:Normal» Major

Patch in #75 works and looks like the best solution.

Can you confirm that the current dev branch is not working? This fix went in already so either it needs revision or we're dealing with a different issue.

Status:Needs review» Closed (fixed)

My bad, you're right, I was on 2.0-unstable7... http://drupalcode.org/project/media.git/commit/e771336

For anyone still experiencing this problem, after much debugging I discovered that the Styles module was changing the DOM structure to something the media browser wasn't able to work with. I'm continuing to debug the problem, I'll post more when I know more.

So it turned out that the reason our site's users couldn't select items in the file browser was because the image file display (admin/structure/file-types/manage/image/file-display) was configured to use a file style directly, once I changed it back to the Image display style with the appropriate image style it worked again and I could select items in the media browser. Should I add a follow-on documentation task for this?

I'm not sure if this belongs here, but I found the issue for me was with AdvAgg #2111695: "You have not selected anything!" when not on page 1 (Media v2)

For anyone using AdvAgg, I opened a new issue to dig into the problem: #2122237: Compatibility problem with Media module's media browser popup