variable_get('media__wysiwyg_title', t('Media browser')), 'vendor url' => 'http://drupal.org/project/media', 'icon path' => drupal_get_path('module', 'media') . '/images', 'icon file' => 'wysiwyg-media.gif', 'icon title' => variable_get('media__wysiwyg_icon_title', t('Add media')), // @todo: move this to the plugin directory for the wysiwyg plugin. 'js path' => drupal_get_path('module', 'media') . '/js', 'js file' => 'wysiwyg-media.js', 'css file' => NULL, 'css path' => NULL, 'settings' => array( 'global' => array( 'enabledPlugins' => variable_get('media__wysiwyg_browser_plugins', array()), 'file_directory' => variable_get('media__wysiwyg_upload_directory', ''), 'types' => variable_get('media__wysiwyg_allowed_types', array('audio', 'image', 'video', 'document')), 'id' => 'media_wysiwyg', ), ), ); return $plugins; } /** * Prepares the page to be able to launch the media browser. * * Defines default variables. */ function media_include_browser_js() { static $included; if ($included) { return; } $included = TRUE; module_load_include('inc', 'media', 'includes/media.browser'); $javascript = media_browser_js(); foreach ($javascript as $key => $definitions) { foreach ($definitions as $definition) { $function = 'drupal_add_' . $key; // Since the arguments to pass are variable, use call_user_func_array(). // This will not handle all potential drupal_add_*() functions directly // but covers the js and library needed here, which are unlikely to be // expanded since this function is only a workaround for a wysiwyg // limitation. call_user_func_array($function, $definition); } } // Add wysiwyg-specific settings. $settings = array('wysiwyg_allowed_attributes' => variable_get('media__wysiwyg_allowed_attributes', array('height', 'width', 'hspace', 'vspace', 'border', 'align', 'style', 'class', 'id', 'usemap', 'data-picture-group', 'data-picture-align'))); drupal_add_js(array('media' => $settings), 'setting'); } /** * Element validate callback for the media WYSIWYG button. */ function media_wysiwyg_button_element_validate($element, &$form_state) { if (!empty($element['#value'])) { $format = filter_format_load($form_state['build_info']['args'][0]->format); $filters = filter_list_format($format->format); if (empty($filters['media_filter']->status)) { form_error($element, t('The Convert Media tags to markup filter must be enabled for the @format format in order to use the Media browser WYSIWYG button.', array( '@format-link' => url('admin/config/content/formats/' . $format->format, array('query' => array('destination' => $_GET['q']))), '@format' => $format->name, ))); } } return $element; }