The media widget seems to open two browsers. I noticed this because when I press cancel there is still a popup, but the background is more transparent.

This creates the "You have not selected anything!" alert because it seems to look for selected files in the other browser.
The popup js checks for selections at: this.contentWindow.Drupal.media.browser.selectedMedia, but this array stays empty. This while images do get added to a selectedMedia array, but probably to the other browser.

I have the latest media dev version. I get this on single and multi value fields and in multiple content types.

Anything leads I can investigate? Should I dig up more information about my installation?

Comments

peteruithoven’s picture

I added a little module to tweak the media widget button title. I wanted to change one instance to "Select image" to make it less abstract.
But this seems the culprit of opening up a second popup. No clue how and why though...
Any tips on doing this in a more proper way are also welcome.

/*
 * Change fabmoment main image button label
 */
// alter the media form item type to change it's process function
function media_browser_protospace_element_info() {
  //drupal_set_message(t('protospace_element_info'), 'error');
  $types = media_element_info();
  $types['media']['#process'] = array('protospace_media_element_process'); 
  return $types;
}
// change the button title of the main image form item 
function protospace_media_element_process(&$element, &$form_state, $form) {
  $element = media_element_process($element, $form_state, $form);
  if($element['#field_name'] == "field_main_image")
    $element['select']['#title'] = "Selecteer afbeelding";
  return $element;
}
peteruithoven’s picture

The trick was using protospace_element_info_alter instead of media_browser_protospace_element_info.

/*
 * Change fabmoment main image button label
 */
function protospace_element_info_alter(&$types) {
  // alter the media form item type to change it's process function
  $types['media']['#process'] = array('protospace_media_element_process');
}
// change the button title of the main image form item 
function protospace_media_element_process(&$element, &$form_state, $form) {
  $element = media_element_process($element, $form_state, $form);
  if($element['#field_name'] == "field_main_image")
    $element['select']['#title'] = "Selecteer afbeelding";
  return $element;
}
peteruithoven’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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