diff -u b/filefield_sources.js b/filefield_sources.js --- b/filefield_sources.js +++ b/filefield_sources.js @@ -29,7 +29,7 @@ // Add the active class. $(this).addClass('active'); Drupal.fileFieldSources.updateHintText($fileFieldElement.get(0)); - }).first().click(); + }).first().triggerHandler('click'); // Clipboard support. $fileFieldElement.find('.filefield-source-clipboard-capture') diff -u b/filefield_sources.module b/filefield_sources.module --- b/filefield_sources.module +++ b/filefield_sources.module @@ -314,20 +314,22 @@ */ function filefield_sources_info($include_default = TRUE) { // Cache the expensive part. - $cache = &drupal_static(__FUNCTION__); - if (!$cache) { - $default = array('upload' => array('name' => 'Upload', 'label' => 'Upload', 'description' => 'Upload a file from your computer.', 'weight' => -10)); - $info = module_invoke_all('filefield_sources_info'); - $info = $default + $info; + $cache = &drupal_static(__FUNCTION__, array()); + if (empty($cache)) { + $cache['upload'] = array( + 'name' => t('Upload (default)'), + 'label' => t('Upload'), + 'description' => t('Upload a file from your computer.'), + 'weight' => -10, + ); + $cache += module_invoke_all('filefield_sources_info'); - drupal_alter('filefield_sources_info', $info); - uasort($info, '_filefield_sources_sort'); - - $cache = $info; + drupal_alter('filefield_sources_info', $cache); + uasort($cache, '_filefield_sources_sort'); } - $info = $cache; - // Maybe don't include the 'upload' type. + // Remove the upload option from the returned value if needed. + $info = $cache; if (!$include_default) { unset($info['upload']); } @@ -636,8 +638,11 @@ } /** - * Helper to return enabled sources for a field, to provide - * backward compatibility for 'upload' type. + * Helper to return enabled sources for a field + * + * This provides backward compatibility for 'upload' type. + * + * @see http://drupal.org/node/932994 */ function _filefield_sources_enabled($settings) { if (!isset($settings['filefield_sources']['upload'])) {