Closed (outdated)
Project:
D7 Media
Version:
7.x-1.x-dev
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 May 2011 at 09:16 UTC
Updated:
25 Jan 2019 at 20:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sanderjp commentedWell I dived in it myself and found that each time you click "Add another item" it adds more entry's in the element array (in media.browser.inc at function 'media_attach_browser_js()' line 301). The variable browserUrl should be the same for each item so doesn't need to be added for each item seperatly.
The problem is in the function 'Drupal.media.popups.mediaBrowser.getDefaults' in media.popups.js (line 107) where it loads the browserUrl. If there is one item, the variable contains '/media/browser?render=media-popup' but more items turns it into an array and the variable outputs '/media/browser?render=media-popup,/media/browser?render=media-popup'.
My solution is not the best way but as far as I've tested it, it works. In media.popups.js, at the function 'Drupal.media.popups.mediaBrowser.getDefaults' (line 107) i've added an if statement to check wether it's an array or not. If so, only take the first entry of the array:
And at line 121, I changed:
src: Drupal.settings.media.browserUrl; // Src of the media browser (if you want to totally override it)
into:
src: browserUrl, // Src of the media browser (if you want to totally override it)
As I said for now it works, but I'm not sure this is the best way to solve it.
Feedback/comments/improvements are welcome :)
Comment #2
james.elliott commentedI would think that the correct fix would be to solve the bug that is turning the url into an array in the first place. Your suggestion fixes the symptom but not the issue.
This will also be irrelevant once #1139514: Overhaul the media browser code to not use an iframe, and be more understandable, maintainable, and extendable makes its way into the main branch.
Comment #3
sanderjp commentedyea, this is just a workaround, will keep an eye on the fat-trimming :)
Comment #4
katbailey commentedAdding sanderjp's work-around as a patch seeing as there's not much point in finding a better solution in parallel with the fat-trimming work that's happening, but there's no telling when that one will make it in and I need this in my make file right now ;-)
Comment #5
langworthy commentedre-roll of #4 against HEAD
Comment #6
langworthy commented#5 is not against HEAD. I'm not sure what I was thinking
Comment #7
webflo commentedthx for the work a round in #5.
Comment #8
madeby commentedThis is still an error in RC1 - I really needs to be addressed for a final release.
Comment #9
gaele commented#5 is working fine for me too.
Edit: #4 is working fine for me too.
Comment #11
gaele commented#4: 1144422-popup-browserurl.patch queued for re-testing.
Comment #12
dave reidI'd rather fix the bug here as well rather than the symptom.
Comment #13
chris matthews commentedClosing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team