You are here

function oembed_test_validate in oEmbed 7.0

Same name and namespace in other branches
  1. 7 oembed.admin.inc \oembed_test_validate()

Validate input by attemping to request URL and generate display.

File

./oembed.admin.inc, line 89
OEmbed admin pages.

Code

function oembed_test_validate($form, &$form_state) {

  // Normalize input and look up
  $url = $form_state['values']['url'];
  $embed = oembed_get_data($url);
  if (!empty($embed)) {
    $form_state['embed'] = check_plain(print_r($embed, TRUE));
    $form_state['display']['oembed'] = oembed_render_element('oembed', $url);
    $form_state['display']['oembed_thumbnail'] = oembed_render_element('oembed_thumbnail', $url);
  }
  else {
    form_set_error('url', t("%input is not valid oEmbed URL. Please check the !link for messages.", array(
      '%input' => $form_state['values']['url'],
      '!link' => l(t("error log"), 'admin/reports/dblog'),
    )));
  }
}