The media browser has great need of code trimming. The implementation in 7.x-1.x-dev has several issues. The major ones I would like to see fixed are in the following list:

  • The media dialog launches to hold an iframe with several tabbed forms within. This creates a suboptimal situation where we are trying to pass events and data to and from the iframe. The implementation is hacky and overly complicated. The most egregious example of this is the code that adds fake submit and cancel buttons that then pass events out of the iframe and click the okay and cancel buttons that are created as part of the jQuery dialog.
  • The code that creates and displays the listings of media at admin/content/media and within the library tab should be the same. We have two separate implementations and UX for selecting pieces of media. This is an unnecessary redundancy of code.
  • Implementing a media browser plugin requires that all functionality be handled by the implementing plugin.

Of these two things, I think that the first is the biggest issue. The complexity of media.popups.js and media.browser.js makes it very difficult to make changes and improvements to the browser. The following is what I would propose as fixes for the current implementation.

  • Rather than calling an iframe inside of a jQuery dialog. Use Drupal's AJAX system to return settings and content to be placed within the jQuery dialog.
  • Transition the implementation of the browser from functions with callback arguments to an event based system
  • Simplify media browser plugin implementation so that it can be extended more easily. This ties into the JS side having an event based system.
  • Alter the media listings so that they are reusable.
  • Re-implement the library plugin in such as way as it is able to use any of the media listing displays
CommentFileSizeAuthor
#49 media_browser_overhaul-1139514-49.patch820 bytesidflood
#48 media_browser_overhaul-1139514-48.patch481 bytesidflood
#37 1139514-37.media-browser-overhaul-2.x.patch136.95 KBksenzee
#29 0001-Issue-1139514-by-effulgentsia-james.elliott-Changed-.patch9.57 KBjames.elliott
#23 media-browser-overhaul-1139514-22.patch127.05 KBeffulgentsia
#22 media-browser-overhaul-1139514-22.patch127.03 KBeffulgentsia
#17 Content | The Urban Child Institute.jpg40.69 KBsafetypin
#9 media-browser-merge.patch126.04 KBeffulgentsia
#5 corolla_theme_media.jpg44.53 KBJacobSingh
#5 another_gardens_customer.jpg46.47 KBJacobSingh
#5 gardens_customer_theme.jpg62.3 KBJacobSingh
#3 media_admin.bugs_.jpg72.12 KBJacobSingh
#3 media_as_field.bugs_.jpg39.96 KBJacobSingh
#3 media_browser_library.bugs-1.png132.45 KBJacobSingh
#3 media_browser2.bugs_.jpg56.74 KBJacobSingh
#3 media_upload.bugs_.jpg39.67 KBJacobSingh
#1 0001-1123534-Remove-the-unneccessary-media.core_.js-file-a.patch4.51 KBjames.elliott
#1 0002-1124758-File-comment-changes.patch1.42 KBjames.elliott
#1 0005-1124682-UnWTFing-media.admin_.js_.patch8.54 KBjames.elliott
#1 0006-Refactor-media-browser-display-on-the-admin-page.patch27.46 KBjames.elliott
#1 0007-Add-pager-to-the-table-view.patch777 bytesjames.elliott
#1 0008-Ditch-the-iframe-and-use-an-AJAX-call-for-a-jQuery-d.patch21.64 KBjames.elliott
#1 0009-Changed-the-display-type-switcher-to-a-separate-menu.patch10.92 KBjames.elliott
#1 0010-Refactor-media-browser.patch22.2 KBjames.elliott
#1 0011-Woo-got-the-display-switching-working.-AJAX-style-wi.patch32.58 KBjames.elliott
#1 0012-Styling-for-the-button-switcher.patch4.87 KBjames.elliott
#1 0013-WYSIWYG-still-broken.patch35.5 KBjames.elliott
#1 0014-woohoo-got-WYSIWYG-up-and-functioning.patch8.55 KBjames.elliott
#1 0015-AJAX-paging-is-working.patch28.73 KBjames.elliott

Comments

james.elliott’s picture

I can't seem to push to git.drupal.org to create a new branch for this, so instead here are 13 patches.

Still left to do is to make sure this doesn't spam the error and warning logs. I haven't checked it lately but along the way I noticed it was getting very spammy.

JacobSingh’s picture

I pushed these changes to http://drupalcode.org/project/media.git/shortlog/refs/heads/1139514_medi...

It does not merge cleanly into the file_entity branch which will soon become the main branch, I'll create another branch to tackle that.

JacobSingh’s picture

Status: Active » Needs work
StatusFileSize
new39.67 KB
new56.74 KB
new132.45 KB
new39.96 KB
new72.12 KB

After initial testing, here are the bugs I've found. All are noted in attached skitches:
media_admin.bugs_.jpg

media_as_field.bugs_.jpg

media_browser_library.bugs-1.png

media_browser2.bugs_.jpg

media_upload.bugs_.jpg

JacobSingh’s picture

A couple quick code things


function media_media_display_types() {
  $path = drupal_get_path('module', 'media');
  $display_types = array();

  $display_types['list'] = array(
    'title' => t('List'),
    'description' => t('Display as a list.'),
    'icon' => $path . '/images/display-list.png',
    'icon_active' => $path . '/images/display-list-active.png',
    'callback' => 'media_browser_table',
    'file' => drupal_get_path('module', 'media') . '/includes/media.admin.inc',
  );

  $display_types['thumbnails'] = array(
    'title' => t('Thumbnails'),
    'description' => t('Display as thumbnails.'),
    'icon' => $path . '/images/display-thumbnails.png',
    'icon_active' => $path . '/images/display-thumbnails-active.png',
    'callback' => 'media_browser_thumbnails',
    'file' => drupal_get_path('module', 'media') . '/includes/media.admin.inc',
  );

  return $display_types;
}

The media_browser_thumbnails function is not in media.admin.inc, you've put it in media.browser.inc. I suppose it belongs in pages.inc tho...

It would be good to add docblocks on the new functions. There are about a dozen in media.browser.inc w/o any docs on them.

JacobSingh’s picture

StatusFileSize
new62.3 KB
new46.47 KB
new44.53 KB

In general, I like not using an iframe, but my concerns are were totally valid. Just add this to your theme's CSS file:

td { padding: 5px; border:2px solid black;}

This will pretty much wreck havok on the list view.

Or if we do:
form {padding:margin:10px} or input {} or various other base HTML tags. jquery will reset the dialog itself, but the contents are up for grabs. I'm not at all confident that this will work in most themes. I think this is why similar javascript widgets often use iframes.

I'm not saying we *can't* fix it, but it's not as simple as "just works".

Here are a few examples. The first is one of the most widely used themes for D7 on d.o
The others are gardens sites I found after picking through a few and testing.

corolla_theme_media.jpg

gardens_customer_theme.jpg

another_gardens_customer.jpg

james.elliott’s picture

Status: Needs work » Active

git solved and some more changes pushed to the branch.

Most of the changes are based on things pointed out here.

#3

Image 1

  • The "Add files" link wasn't working because the file element that is made invisible and placed above it wasn't positioning correctly. This is a plupload fragility that I worked around by having the link trigger a click event on the file field
  • The "Start upload" link was hidden via CSS that no longer applied because there wasn't the same body class because we're no longer in the iframe. I rescoped the selector and the button has gone bye bye
  • The Okay button has not been updated to say "Start upload" again and will trigger plupload

Image 2

  • I haven't been able to replicate the media_fid_illegal_value error, I assume that is related to the browser not restricting types. That should be solved now

Image 3

  • Links in the browser should no longer go to their targets. They should instead select the checkbox for that row.

Image 4

  • The styling for the dialog should be more inline with what it was originally. I only overwrote styling that comes with the jQuery library and nothing that was added for jQuery dialogs within the Seven theme. The Seven styling seems to be overridden by the defaults, so I'm not sure if that means there is a Seven bug there.
  • The Web tab should now properly send fids to the callback so that the dialog will close and the caller be updated
  • Styling for the ajax throbber is updated

Image 5

  • Types should now be respected

#4

I added documentation and comments to almost everything that was changed.

#5

I tried the suggested styles and other than thinking that the border on the tds was ugly, I didn't find any issues. I would submit that a theme that outputs hideous or unreadable styling for theme_table or a jquery ui dialog is a bad theme and that faults there should be attributed to the theme and not the module that added the markup.

Case in point would be the example of Corolla that you posted a picture of. .form-item.form-type-checkbox is an overly specific selector. .form-type-checkbox isn't going to be found without .form-type also existing on the same element. Scoping as such is probably an issue with the theme in general.

Thanks for the feedback. Now I just need to fold in the file entity changes that effulgentsia has been working on.

JacobSingh’s picture

I don't think we can say "blame the theme" Especially in Gardens where you have total amateurs using a GUI tool to change the styles. For instance, take a stock product theme, love the black background.

james.elliott’s picture

I forgot to update this issue, but I folded in the file_entity changes to the branch.

I also added a few enhancements to the thumbnail media browser.

You can now use SHIFT and CTRL modifiers when multi select is enabled.

  • SHIFT will always add more items
  • CTRL will toggle the select status of items

A more massive UX change is the ability to select thumbnails by clicking and dragging a select box, much like in most OSes.

effulgentsia’s picture

StatusFileSize
new126.04 KB

I'm not sure if I'm looking at the right code. Just to check, what I did was push into the 1139514_media_browser_fat a merge of 7.x-1.x commits that happened since you merged the file entity work. And I also changed 2 files from Windows line endings to Unix line endings.

In case it helps, I'm adding a patch here of 1139514_media_browser_fat changes relative to current 7.x-1.x. Please inspect either this patch or the git branch to see if it has the correct code, or if there's some artifacts of a merge gone bad.

On a fresh D7 install, if I just install the Media module, here's what I get when I try to add media from admin/content/media: https://skitch.com/effulgentsia/r9dhp/content-localhost.

If I then also enable WYSIWYG, here's what I get when using its toolbar: https://skitch.com/effulgentsia/r9dh5/create-article-localhost.

I decided to stop my review at that point, as there's probably something obviously going wrong that I'm hoping you can shed some light on.

effulgentsia’s picture

Title: Trim the fat in the media browser code » Improve the media browser code to not use an iframe, and be more understandable, maintainable, and extendable
Priority: Normal » Major

Better title? Also, upping to "major", since this is pretty huge and awesome, once the bugs are worked out.

effulgentsia’s picture

Title: Improve the media browser code to not use an iframe, and be more understandable, maintainable, and extendable » Overhaul the media browser code to not use an iframe, and be more understandable, maintainable, and extendable

even more catchy title in the hopes that people who might care about this have a chance to see it.

fangel’s picture

Subscribing.

james.elliott’s picture

Initial observation of the patch leads me to believe that media.admin.inc didn't merge correctly. I'll take a look at it as soon as I'm able.

anavarre’s picture

Subscribing

FrequenceBanane’s picture

subscribe

yareckon’s picture

sub

safetypin’s picture

StatusFileSize
new40.69 KB

I was about to create a new issue, but the resolution of this problem will make the browser more useful/understandable.

The media selection interface (the browser) displays thumbnails, with a severely shortened file name. This causes a real problem if you have any number of files that begin with the first 15 characters. For example, a PDF that is broken out into sections, so that a visitor can download the whole PDF, or just a section of it if they want. I've attached a screenshot of our current situation that is causing this problem. I can think of two possible solutions, I'll look into both of them when I have a chance.

  1. Provide a "list view" and "thumbnail view" options like the admin/content/media page
  2. Give each media item listed a "title" attribute with the full file name, so that when hovering over the item, we get the full name in a tool tip

I'm guessing that 2 is easier, but 1 would be way nicer.

james.elliott’s picture

I've got a less than completely broken version with the latest 7.x-1.x changes added to the branch now.

The places where I still need to figure out what has gone wrong are as follows:

  • The media format form is not displaying itself properly
  • The multiselect parameter is not being passed to the dialog correctly. WYSIWYG should only be single select.
james.elliott’s picture

Just pushed some new changes up that should have everything working again.

eigentor’s picture

About the CSS issues - I am experiencing the same with the toolbar all to often: some fancy CSS style in my theme messes with the fontsize of the toolbar, and everytime I think: someone has not thought enough of this.
Would it be a solution to bruteforce lock the design by having a cascade like
#media-wrapper #browser-window #inner-wrapper .yourclass and then adding CSS for the Browser and other elements that style the interface?

I see that is ugly, but a theme would need three nested IDs in selectors to break this (or is my CSS knowledge mistaken).
We often want clean CSS and not too much nesting in Html. But Themes breaking modules and core CSS is a serious and visible problem and maybe such a pragmatic approach could help the iframe - no iframe issue.

bastnic’s picture

subscribe

effulgentsia’s picture

Status: Active » Needs review
StatusFileSize
new127.03 KB

I pushed up a few minor fixes to the issue branch, as well as some merges from 7.x-1.x that were dropped for some reason from #18.

Here's an up to date patch file representing this issue's work relative to 7.x-1.x. Still needs review. Will start on that shortly.

effulgentsia’s picture

StatusFileSize
new127.05 KB
+++ b/js/wysiwyg-media.js
@@ -35,17 +38,20 @@ Drupal.wysiwyg.plugins.media = {
+    Drupal.ajax[instanceId+'-ff'].element_settings.url = Drupal.basePath + 'media/' + mediaFile.fid + '/format-form';
+    Drupal.ajax[instanceId+'-ff'].options.url = Drupal.basePath + 'media/' + mediaFile.fid + '/format-form';

s/Drupal.basePath/Drupal.settings.basePath/

That was preventing ability to test insertion to wysiwyg, so pushed fix to feature branch, and am uploading modified patch.

g76’s picture

sub

effulgentsia’s picture

Status: Needs review » Needs work

This is very incomplete (the patch is large), but here's a partial review. Will post more when I have a chance.

+++ b/includes/media.admin.inc
@@ -81,165 +48,38 @@ function media_admin($form, $form_state) {
-function media_admin_validate($form, &$form_state) {
+function media_admin_delete_validate($form, &$form_state) {

Why change this function name? Even if "delete" is the only current bulk operation, couldn't more operations be added later?

+++ b/includes/media.filter.inc
@@ -269,6 +279,30 @@ function _media_generate_tagMap($text) {
+function media_format($media) {

This function (and all new functions) needs a docblock. Also, s/$media/$file/.

+++ b/includes/media.filter.inc
@@ -278,6 +312,10 @@ function _media_generate_tagMap($text) {
+  drupal_add_css(drupal_get_path('module', 'media') . '/css/media.thumbnails.css');

Later in this function, CSS is attached with #attached. Can this be as well? Also, can all attached files be attached in the same place, rather than some at the beginning of the function, and some at the end?

+++ b/includes/media.filter.inc
@@ -320,7 +358,7 @@ function media_format_form($form, $form_state, $file) {
-  $form['#attached']['js'][] = $path . '/js/media.format_form.js';
+  #$form['#attached']['js'][] = $path . '/js/media.format_form.js';

If this JS file is no longer relevant, can this line be deleted rather than commented out?

+++ b/includes/media.filter.inc
@@ -361,6 +399,33 @@ function media_format_form($form, $form_state, $file) {
+      '#value' => isset($form_state['values']['trigger']) ? $form_state['values']['trigger'] : $_POST['trigger'],

Why is this needed? Doesn't FAPI do this automatically (and with greater security)?

+++ b/media.module
@@ -252,10 +259,15 @@ function media_menu() {
+function media_dialog_theme() {
+  $ajax_theme = isset($_POST['ajax_page_state']['theme']) ? $_POST['ajax_page_state']['theme'] : variable_get('theme_default', 'bartik');
+  return $ajax_theme;
+}
+

Why use this function at all instead of ajax_base_page_theme(), which implements better security?

+++ b/media.module
@@ -423,36 +433,6 @@ function media_styles_style_flush($style) {
-function media_page_alter(&$page) {
-  // Show a nagging message when the media installation needs to be completed.
-  if (user_access('administer media') && media_variable_get('show_file_type_rebuild_nag')
-    // Prevent form submissions from creating duplicate messages.
-    && ($_SERVER['REQUEST_METHOD'] == 'GET')
-    // Show on all the admin pages, except the batch and the rebuild form.
-    && path_is_admin(current_path()) && (arg(0) != 'batch') && (current_path() != 'admin/config/media/rebuild_types')) {
-    drupal_set_message(t('Media module install is not complete. <a href="@type_rebuild_link">Finish the install</a>.', array('@type_rebuild_link' => url('admin/config/media/rebuild_types'))), 'warning', FALSE);
-  }

This part is still needed.

+++ b/media.module
@@ -962,13 +952,13 @@ function media_element_process(&$element, &$form_state, $form) {
+//  $setting['media']['elements'][$element['#id']] = $element['#media_options'];

If we're commenting this out, then should at least #media_options still be used somewhere above?

Powered by Dreditor.

effulgentsia’s picture

+++ b/media.api.php
  * - #weight (optional): Weight of the plugin in relation to other plugins
  *  when being displayed, e.g. tabs in the browser.
+ * - #title  (required): The title of the tab to be displayed in the media browser
+ * - #form_id (required): The name of the form that will be used to select media
+ * ¶
+ * Within this function the implementor is responsible to call any required
+ * module_load_include calls so that the central browser processing callback
+ * can process the form correctly.
  *
  * @example
  * <code>
+ * ¶
+ * module_load_include('inc', 'my_module', 'my_include');
+ * ¶
  * array(
  *  'unique_plugin_name' => array(
+ *     '#title' => 'unique_plugin_tab_name',
+ *     '#form_id' => 'unique_plugin_form_id',
  *     '#weight' => 42,
  *   ),
  * );

So, this patch removes hook_media_browser_plugin_view() and modifies what's expected from hook_media_browser_plugin_info(). I can't tell yet if this BC break is necessary or not. If it's not, then let's not do it. But if some BC break around media browser plugins is needed in order to accommodate the switch to an AJAX-based rather than iframe-based browser, then let's use the opportunity to do it right, since once we release RC1, we won't have an opportunity for another BC break until we start on Media version 2, and that might not be for a while.

What do I mean by "do it right"? We should use CTools plugins, of course. The dev version of Media now depends on CTools anyway. If you haven't worked with CTools plugins before, read up on "help/plugins-creating.html" and "help/plugins-implementing.html" within the CTools module. In addition to the many other benefits that come with following what is now the defacto Drupal standard for how to work with plugins, the ctools_plugin_get_function() function has built-in support for lazy loading. This lets us avoid requiring plugins to call module_load_include() within their info definition, which is good, since we need to get the info for all plugins when we launch the browser, but we don't really need the form callback included until we go to that plugin's tab.

tirdadc’s picture

subscribe

logaritmisk’s picture

subscribe

james.elliott’s picture

This is in response to #25

This is very incomplete (the patch is large), but here's a partial review. Will post more when I have a chance.

+++ b/includes/media.admin.inc
@@ -81,165 +48,38 @@ function media_admin($form, $form_state) {
-function media_admin_validate($form, &$form_state) {
+function media_admin_delete_validate($form, &$form_state) {

Why change this function name? Even if "delete" is the only current bulk operation, couldn't more operations be added later?

I think this was a partial change that I later backed out and somehow still made it into the commit. Reverted in the latest.

+++ b/includes/media.filter.inc
@@ -269,6 +279,30 @@ function _media_generate_tagMap($text) {
+function media_format($media) {

This function (and all new functions) needs a docblock. Also, s/$media/$file/.

Done and done. At least, where I found that there were missing docblocks.

+++ b/includes/media.filter.inc
@@ -278,6 +312,10 @@ function _media_generate_tagMap($text) {
+  drupal_add_css(drupal_get_path('module', 'media') . '/css/media.thumbnails.css');

Later in this function, CSS is attached with #attached. Can this be as well? Also, can all attached files be attached in the same place, rather than some at the beginning of the function, and some at the end?

This is a pattern that should be fixed throughout the module. I propose we attach at the beginning of functions.

+++ b/includes/media.filter.inc
@@ -320,7 +358,7 @@ function media_format_form($form, $form_state, $file) {
-  $form['#attached']['js'][] = $path . '/js/media.format_form.js';
+  #$form['#attached']['js'][] = $path . '/js/media.format_form.js';

If this JS file is no longer relevant, can this line be deleted rather than commented out?

Deleted the line and the referenced file.

+++ b/includes/media.filter.inc
@@ -361,6 +399,33 @@ function media_format_form($form, $form_state, $file) {
+      '#value' => isset($form_state['values']['trigger']) ? $form_state['values']['trigger'] : $_POST['trigger'],

Why is this needed? Doesn't FAPI do this automatically (and with greater security)?

This isn't the same as the FAPI trigger. This doesn't pertain to the submit button, but instead to the element that called for the dialog to be created. e.g. The longtext element in which the WYSIWYG button was clicked. Perhaps the issue here is the unfortunate usage of "trigger" instead of a more unique word.

+++ b/media.module
@@ -252,10 +259,15 @@ function media_menu() {
+function media_dialog_theme() {
+  $ajax_theme = isset($_POST['ajax_page_state']['theme']) ? $_POST['ajax_page_state']['theme'] : variable_get('theme_default', 'bartik');
+  return $ajax_theme;
+}
+

Why use this function at all instead of ajax_base_page_theme(), which implements better security?

This is simply due to not having found the ajax_base_page_theme() function.

+++ b/media.module
@@ -423,36 +433,6 @@ function media_styles_style_flush($style) {
-function media_page_alter(&$page) {
-  // Show a nagging message when the media installation needs to be completed.
-  if (user_access('administer media') && media_variable_get('show_file_type_rebuild_nag')
-    // Prevent form submissions from creating duplicate messages.
-    && ($_SERVER['REQUEST_METHOD'] == 'GET')
-    // Show on all the admin pages, except the batch and the rebuild form.
-    && path_is_admin(current_path()) && (arg(0) != 'batch') && (current_path() != 'admin/config/media/rebuild_types')) {
-    drupal_set_message(t('Media module install is not complete. <a href="@type_rebuild_link">Finish the install</a>.', array('@type_rebuild_link' => url('admin/config/media/rebuild_types'))), 'warning', FALSE);
-  }

This part is still needed.

Added this section back in.

+++ b/media.module
@@ -962,13 +952,13 @@ function media_element_process(&$element, &$form_state, $form) {
+//  $setting['media']['elements'][$element['#id']] = $element['#media_options'];

If we're commenting this out, then should at least #media_options still be used somewhere above?

I've changed this to use #media_options to set the allowable types for a media field.

thebuckst0p’s picture

Subscribe. I would like to alter the tabs (Web / Upload / Library) depending on the role, that doesn't seem easy to do now, but making the whole popup follow standard ajax/tab standards would be helpful.

ksenzee’s picture

We do need the BC break for plugins to switch away from an iframe. So I made a commit to the feature branch yesterday that implements ctools plugin support. I merged in the 7.x-1.x branch as well, so the branch is up to date. I don't have it documented at all though - I'm not even sure how to document a ctools plugin requirement. :/

grossmann’s picture

subscribe

dave reid’s picture

Component: Code » Media Browser
JacobSingh’s picture

It's nice to see this issue getting some more love (Dave). Let's consider the CSS bleedthrough issue w/o the iframe a bit too. I demonstrated how fragile it is earlier, it would be nice to take some measures to protect it from themes going bananas.

effulgentsia’s picture

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

Re #34: In Drupal Gardens, we have a fairly robust (probably not 100% robust) CSS reset file that we use for the Theme Builder. Next chance I have, I'll clean that up, and attach it to this issue for testing and review.

Additionally, some consensus is emerging on #1175830-27: Update to jQuery UI 1.10.2. We may want to factor that in to the code being proposed in this issue.

We may also want to consider adding the CSS reset and whatever is needed for accessibility as per above into the Dialog API project, and make the Media browser use that module.

Also, moving this issue to 2.x. All new code needs to go into there first. Some issues could get backported if there's motivation to do so, but this one probably won't, as it involves major BC breaks.

hernani’s picture

Subscribe

ksenzee’s picture

StatusFileSize
new136.95 KB

I merged the 2.x branch into the 1139514_media_browser_fat branch (where did the 'fat' come from btw?). Here's the diff between that branch and 7.x-2.x, for those following along at home.

desierto’s picture

Just a quick FYI of one problem I experience with the iframe popup - often I get my entire website popping up in the iframe and not just the file upload dialog. Sometimes it works appropriately. I haven't noticed any pattern that causes it.

ksenzee’s picture

desierto, you mean that happens without this patch applied, right?

desierto’s picture

Sorry to confuse... yes my issues are without the patch. I know this thread has worked up a patch... I was just mentioning one of the issues with using iframes. I have not tried the patch as my site is on a shared host and I'd have to apply it manually... it takes too much time with the numerous patches for various modules, some pretty complicated.

jide’s picture

That's a nice improvement, that iframe popup was a strange thing.

I'd like to implement the browser as form fields directly in the node form, without popups, in order to be able to have fields for "Upload", "Web" and "Library" displayed as normal fields, populating the media field itself, but it is more difficult than I thought - these changes to the popup make it a little easier though.

That would let the user type in a URL in a textfield without having to open the popup beforehand, similar to what facebook does.

Are there any plans for this ? Interest ? Ideas ?...

jide’s picture

BTW, I'm confused about what version should these patches be applied against ? It seems that the "fat" branch has the last patch applied though.

acbramley’s picture

@desierto in reply to #38 I have found this happens to me too. I get the admin menu in the iframe popup which pushes the submit and cancel buttons out of the frame. This seems to happen only after clicking "Add another item" on the node edit form. I created a bug for this too http://drupal.org/node/1264982

acbramley’s picture

How do I test this? I've checked out the 1139514_media_browser_fat git branch and copied it into my drupal install.

After drush en media I get:

The following extensions will be enabled: file_entity, media
Do you really want to continue? (y/n): y
PHP Fatal error:  Call to undefined function media_type_invalid_files_count() in ...sites/all/modules/contrib/media/media.install on line 83
acbramley’s picture

Then on uninstall I get:

PHP Fatal error:  Call to undefined function media_variable_default() in /home/adamb/projects/mohbigbird/sites/all/modules/contrib/media/media.install on line 104
idflood’s picture

subscribing.

ddanier’s picture

subscribing

idflood’s picture

StatusFileSize
new481 bytes

I wanted to work a little on that issue and found a little problem. The media browser popup loads a wrong path if the drupal is installed in a subdirectory (only found this issue on the 'fat' branch).

Here is a minimalist patch just for that.

edit: I was thinking about using ctools to make media reinvent less stuff (modal and maybe some ajax stuff). The more I think about it the more I doubt. What do you think?

idflood’s picture

StatusFileSize
new820 bytes

Should have checked the code arround for other instances of the same issue as above. One more in this patch.

ZuluWarrior’s picture

Sub,

So where are we with all this? I have a site that's very close to launch and the library issues discussed here are very relevant to the project.

I am a little confused with the wealth of patches in here, what versions am I needing to get the latest version? I can git clone the 1139514_media_browser_fat branch but what patches from here are required on top?

rickvug’s picture

subscribe

rickvug’s picture

I just tested the code in the media browser fat branch and the final insert of an image does not work. The error is "Uncaught ReferenceError: CKEDITOR is not defined" on line 72 of wysiwyg-media.js. Seeing as how I'm using TinyMCE there I'd expect that the problem is somehow tied to the new media library code coupled to CK Editor.

dave reid’s picture

Issue tags: +Media Sprint 2011
Anonymous’s picture

Assigned: Unassigned »
effulgentsia’s picture

Assigned: » Unassigned
Status: Needs work » Closed (won't fix)

I discussed this with james.elliott, bangpound, and a bunch of other people, and consensus is that removing the iframe is not viable. As initially pointed out in #5, we need to isolate the media browser contents from receiving unexpected base page theme CSS. By default, the media browser contents should be rendered in the admin theme (a site should be able to override this, of course, but that's the expected default behavior). Per #35, I thought we could implement CSS isolation in the media browser with an appropriately constructed reset file, but the challenge with that is that we want to replace the media browser's library tab with a View (#1224766: Remove default media browser and replace with a default view), and that can lead to various 3rd party libraries providing CSS that we won't be able to reset to. So, unless someone comes up with a brilliant idea for how to resolve this, I'm afraid we're stuck with an iframe as the only technology that provides the needed CSS isolation.

So, I'm closing this issue. Apologies to everyone who invested lots of time in it. However, it wasn't a complete loss. In the course of this issue, James and several other people (re)familiarized themselves with some of the legacy crufty JavaScript code, and so in separate issues, as these people have time, they'll be posting some smaller, digestible issues to incrementally make the JavaScript easier to maintain.

I am a little confused with the wealth of patches in here, what versions am I needing to get the latest version? I can git clone the 1139514_media_browser_fat branch but what patches from here are required on top?

All patches posted in the Media issue queue should be rolled against the 7.x-2.x branch. We should delete the 1139514_media_browser_fat branch at this point, but I don't want to do that quite yet, in case people who experimented in that branch want to look back on that branch's history and repurpose some of that work into new patches.

fearlsgroove’s picture

Status: Closed (won't fix) » Active

I'm reopening this with the hope that there's stomach to reconsider this decision. It sounds like this came down to the inability to do complete CSS isolation without an iframe, but imho that's a misguided conclusion. It just seems wrong from a purists' standpoint to be forced in to kludgy, x-iframe javascript communication and cruft-filled markup just to satisfy a very high level presentation (CSS!) requirement.

I've been putting effort into cleaning up a number of the modules we use in nearly all projects to use standard JQuery UI-based markup (and widgets) wherever relevant, in particular replacing custom widgets with stock jquery ui equivalents. I've also created a jQ UI theme for the admin theme we use (Rubik) with the hope of creating a very slick and consistent administrative user experience.

I took a look at media for the first time in a while and was thrilled to see how much more stable it was, and since media's using a jquery ui dialog I thought it would fall right in line with the rest of my efforts, but the wierd title-bar hiding, extra elements in the markup, and finally the iframe and control buttons stopped that effort in it's tracks.

Can you point out any specific examples of what third party tools would add in CSS -- particularly when using a view -- that's so egregious as to make media browser unusable? Could the maintainers provide any feedback on the approach of stripping out a great deal of the style css that's current in the browser code and relying more on jquery to produce a themable consistent look and feel that works with whatever admin theme is in place (assuming it's got a reasonable jquery UI implementation, or works ok with the built in jquery UI theme)?

dddave’s picture

Status: Active » Closed (won't fix)

I am closing this again as it seems to me that there is no progress in sight and the issue was closed already by one of the maintainers.

If there is still interest in tackling this I highly recommend participating in the Media Office hours which happen bi-weekly. Dates can be found on the Media Group page.