I'm attempting to create some extension modules for the media project without modifying the project code at all. I'm currently a little confused why media browser output is limited to a single file, even though it accepts an object. Specifically:
// in media.js
$('.launcher', this).bind('click', function () {
// Launch the browser, providing the following callback function
// @TODO: This should not be an anomyous function.
Drupal.media.popups.mediaBrowser(function (mediaFiles) {
if (mediaFiles.length < 0) {
return;
}
var mediaFile = mediaFiles[0];
// Set the value of the filefield fid (hidden).
fidField.val(mediaFile.fid);
// Set the preview field HTML.
previewField.html(mediaFile.preview);
// Show the Remove button.
removeButton.show();
}, globalOptions);
return false;
});
I would love to see this callback loop through media files rather than explicitly using mediaFiles[0]. Even though the current module only uses [0], it shouldn't break functionality to loop a single time there. In addition, it seems it would be very useful to optionally return a callback mediaFile.callback to execute when the file(s) is returned from the browser successfully. Thoughts?
Comments
Comment #1
gmclelland CreditAttribution: gmclelland commentedDon't know enough to answer your question, but you might want to look at http://drupal.org/sandbox/fangel/1652676 the Media Multiselect module. It seems to work like a champ.
Comment #2
ParisLiakos CreditAttribution: ParisLiakos commentedagreed
not sure about that though without checking the code
Comment #3
Chris Matthews CreditAttribution: Chris Matthews as a volunteer 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