The media browser functionality (media.library.js) is broken.

The desired functionality is to load in more results when the iframe window reaches the bottom of the window, but the logic used here is unsound.

I'm submitting a patch to use the appropriate logic. All other functionality seems to be working well.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mike-n-garrett’s picture

Attached is the patch.

ParisLiakos’s picture

Priority: Major » Normal
Status: Patch (to be ported) » Needs review

but the logic used here is unsound.

what you mean with this..seeing your patch you just convert the jquery calls to plain javascript ones. the functionality should be the same

DamienMcKenna’s picture

DamienMcKenna’s picture

mike-n-garrett’s picture

@ParisLiakos: the use of jQuery in the code was not working at all. It wasn't just that the code had errors it was that the use of jQuery in this circumstance was wrong.

Any way we can get this into the next release of this module?

Anonymous’s picture

Just added it to my site, and it is now working.

xaqrox’s picture

Also working for me. Thanks!

DamienMcKenna’s picture

FYI, for anyone using AdvAgg it's recommended to update it to v7.x-2.3, which fixes some compatibility problems there.

DamienMcKenna’s picture

Title: Media Browser only shows 1 page of results » Media Browser only shows 1 page of results (Media v1)
Issue summary: View changes

Lets keep this focused on v1, which has very different JS than v2.

DamienMcKenna’s picture

Priority: Normal » Major

Bumping this to a Major bug report as it's kind of a glaring problem.

jcfiala’s picture

Status: Needs review » Reviewed & tested by the community

I applied it to the media module and it's really helping, although I notice that the browser only shows the first 40 items in total.

But, the javascript now works.

jaredcampbell’s picture

This also partially fixes https://drupal.org/node/2089697

rcodina’s picture

I can confirm patch on #1 works for me on Media 7.x-1.4! It also works well in combination with the patch from ekristen user found here:

https://drupal.org/node/2089697

This other patch makes media 7.x-1.X compatible with newer versions of jQuery (>1.5). See https://drupal.org/node/2089697#comment-8823747

dooug’s picture

I second the message in comment #13 above.

agileadam’s picture

Just as a heads-up, because this issue is where I started my troubleshooting: I was unable to get anything more than the first page of results in the Library tab due to a non-unique #scrollbox div. I found the culprit to be the brightcove_media module. I realized this because Drupal.media.browser.library.prototype.scrollUpdater() wasn't being called. The scroll bind on #scrollbox wasn't working. I found two divs sharing the same ID. I fixed this here: #2350197: Using non-unique ID on several elements

bcjmpr’s picture

I'm using jQuery Update 7.x-2.4, and another solution could be to select version 1.5 of jQuery on "Alternate jQuery version for administrative pages" in the module settings. Doing that, I could finally see the library when adding content.

Tomefa’s picture

Thanks for the patch, it works fine now !
I think it's a good idea to make a new release of the media module, because that's a really annoying bug on almost all the recent website.

Same comment goes for the patch here : https://www.drupal.org/node/2089697

steinmb’s picture

Version: 7.x-1.3 » 7.x-1.x-dev

Unable to reproduce this error in the latest dev. Are all that sees this bug using jquery_update?

steinmb’s picture

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

@steinmb Yes, we are using jquery_update module.

steinmb’s picture

Try upgrading to 7.x-1.x-dev.

szczesuil’s picture

yay. patch #1 worked for me. thanks so much. i was having to upload files multiple times. it was a drag. besos.

Tomefa’s picture

Steinmb, i didn't try with the dev version but because it's for a production website i can't.
They won't accept a dev module :/

But if the dev fix this and become stable, may be it's time for a new release of media ?

jacktonkin’s picture

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

The code in both 7.x-1.4 and 7.x-1.x-dev is incompatible with jQuery 1.6 or greater.

In prior versions of jQuery the attr() method retrieved DOM properties as well as attributes. This changed in version 1.6 with the introduction of the prop() method. The patch in #1 above correctly (IMO) uses regular javascript to retrieve the scrollTop, scrollHeight and clientHeight properties, fixing the issue for newer versions of jQuery while maintaining compatibility with jQuery 1.5.

I have tested this patch against 7.x-1.x-dev using jQuery 1.5 and 1.7 and it works with both.

Anonymous’s picture

Great patch, we're using on a site with jquery_update with the patch for #2089697: JQuery update break media browser. N0 media elements are displayed in the media library tab.

  • aaron committed 34b1824 on 7.x-1.x
    Issue #2104493 by mikengarett: fixed Media Browser only shows 1 page of...
aaron’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

berenddeboer’s picture

Works on Chrome, doesn't work on FireFox 36.0.1.

berenddeboer’s picture

This patch makes no sense whatsoever. It replaces perfectly fine jQuery with plain javascript. No logic change whatsoever!

Why was this actually committed?

berenddeboer’s picture

And I finally see #24, OK, that makes more sense, and I suppose to keep compatibility between jQuery 1.4 and newer versions just plain javascript is used.

berenddeboer’s picture

False alarm for FireFox, due to .js file being dynamically served, wasn't reloaded even with Ctrl+R to reload the page.