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.
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.
Comment | File | Size | Author |
---|---|---|---|
#1 | media-browser-pagination-2104493.patch | 850 bytes | mike-n-garrett |
Comments
Comment #1
mike-n-garrett CreditAttribution: mike-n-garrett commentedAttached is the patch.
Comment #2
ParisLiakos CreditAttribution: ParisLiakos commentedwhat you mean with this..seeing your patch you just convert the jquery calls to plain javascript ones. the functionality should be the same
Comment #3
DamienMcKennaClosed another duplicate: #2111695: "You have not selected anything!" when not on page 1 (Media v2)
Comment #4
DamienMcKennaRelated: #1956620: Pager on library tab always reloads page 1.
Comment #5
mike-n-garrett CreditAttribution: mike-n-garrett commented@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?
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedJust added it to my site, and it is now working.
Comment #7
xaqroxAlso working for me. Thanks!
Comment #8
DamienMcKennaFYI, for anyone using AdvAgg it's recommended to update it to v7.x-2.3, which fixes some compatibility problems there.
Comment #9
DamienMcKennaLets keep this focused on v1, which has very different JS than v2.
Comment #10
DamienMcKennaBumping this to a Major bug report as it's kind of a glaring problem.
Comment #11
jcfiala CreditAttribution: jcfiala commentedI 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.
Comment #12
jaredcampbell CreditAttribution: jaredcampbell commentedThis also partially fixes https://drupal.org/node/2089697
Comment #13
rcodina CreditAttribution: rcodina commentedI 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
Comment #14
dooug CreditAttribution: dooug commentedI second the message in comment #13 above.
Comment #15
agileadamJust 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
Comment #16
bcjmpr CreditAttribution: bcjmpr commentedI'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.
Comment #17
Tomefa CreditAttribution: Tomefa commentedThanks 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
Comment #18
steinmb CreditAttribution: steinmb commentedUnable to reproduce this error in the latest dev. Are all that sees this bug using jquery_update?
Comment #19
steinmb CreditAttribution: steinmb commentedComment #20
rcodina CreditAttribution: rcodina commented@steinmb Yes, we are using jquery_update module.
Comment #21
steinmb CreditAttribution: steinmb commentedTry upgrading to 7.x-1.x-dev.
Comment #22
szczesuil CreditAttribution: szczesuil commentedyay. patch #1 worked for me. thanks so much. i was having to upload files multiple times. it was a drag. besos.
Comment #23
Tomefa CreditAttribution: Tomefa commentedSteinmb, 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 ?
Comment #24
jacktonkin CreditAttribution: jacktonkin commentedThe 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.
Comment #25
Anonymous (not verified) CreditAttribution: Anonymous commentedGreat 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.
Comment #27
aaron CreditAttribution: aaron commentedCommitted to http://drupalcode.org/project/media.git/commit/34b1824.
Comment #29
berenddeboer CreditAttribution: berenddeboer commentedWorks on Chrome, doesn't work on FireFox 36.0.1.
Comment #30
berenddeboer CreditAttribution: berenddeboer commentedThis patch makes no sense whatsoever. It replaces perfectly fine jQuery with plain javascript. No logic change whatsoever!
Why was this actually committed?
Comment #31
berenddeboer CreditAttribution: berenddeboer commentedAnd 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.
Comment #32
berenddeboer CreditAttribution: berenddeboer commentedFalse alarm for FireFox, due to .js file being dynamically served, wasn't reloaded even with Ctrl+R to reload the page.