function oembed_field_attach_validate in oEmbed 8
Same name and namespace in other branches
- 7 oembed.filter.inc \oembed_field_attach_validate()
- 7.0 oembed.filter.inc \oembed_field_attach_validate()
Implements hook_field_attach_validate().
File
- ./
oembed.filter.inc, line 118 - Input filter that enhances oEmbed enabled URLs with extra content
Code
function oembed_field_attach_validate($entity_type, $entity, array &$errors) {
foreach (_oembed_field_extract_urls($entity_type, $entity) as $field_name => $items) {
foreach ($items as $delta => $item) {
foreach ($item as $column => $urls) {
$messages = array();
foreach ($urls as $url) {
$embed = oembed_get_data($url);
$validation_errors = oembed_validate_response($embed);
if (!empty($validation_errors)) {
$message = t('!url could not be embedded.', array(
'!url' => l(_filter_url_trim($url, 50), $url),
));
$message .= theme('item_list', array(
'items' => $validation_errors,
));
$messages[] = $message;
}
}
if (!empty($messages)) {
$errors[$field_name][$entity->language][$delta][] = array(
'error' => 'oembed_' . $column,
'message' => theme('item_list', array(
'items' => $messages,
)),
'repeat' => TRUE,
);
}
}
}
}
}