You are here

function media_wysiwyg_wysiwyg_button_element_validate in D7 Media 7.3

Same name and namespace in other branches
  1. 7.4 modules/media_wysiwyg/media_wysiwyg.module \media_wysiwyg_wysiwyg_button_element_validate()
  2. 7.2 modules/media_wysiwyg/media_wysiwyg.module \media_wysiwyg_wysiwyg_button_element_validate()

Element validate callback for the media WYSIWYG button.

1 string reference to 'media_wysiwyg_wysiwyg_button_element_validate'
media_wysiwyg_form_wysiwyg_profile_form_alter in modules/media_wysiwyg/media_wysiwyg.module
Implements hook_form_FORM_ID_alter().

File

modules/media_wysiwyg/media_wysiwyg.module, line 219
Primarily Drupal hooks.

Code

function media_wysiwyg_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 <em>Convert Media tags to markup</em> filter must be enabled for the <a href="@format-link">@format format</a> 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;
}