function taxonomy_image_validate_external in Taxonomy Image 6
Check an external link.
1 string reference to 'taxonomy_image_validate_external'
File
- ./
taxonomy_image.module, line 594 - taxonomy_image.module Simple module for providing an association between taxonomy terms and images. Written by Jeremy Andrews <jeremy@kerneltrap.org>, May 2004.
Code
function taxonomy_image_validate_external($form, &$form_state) {
if (empty($form_state['values']['taxonomy_image_external'])) {
return;
}
$url = $form_state['values']['taxonomy_image_external'];
if (!valid_url($url)) {
form_set_error('taxonomy_image_external', t('The URL (@url) you entered does not appear to be valid.', array(
'@url' => $url,
)));
return;
}
$pieces = parse_url($form_state['values']['taxonomy_image_external']);
if ($pieces['scheme'] != 'http' && $pieces['scheme'] != 'https') {
form_set_error('taxonomy_image_external', t('The URL (@url) you entered does not appear to be valid.', array(
'@url' => $url,
)));
return;
}
// Find the stuff after the last period (file type).
$type = drupal_strtolower(substr($pieces['path'], strrpos($pieces['path'], '.') + 1));
$permitted = explode(' ', TAXONOMY_IMAGE_IMAGE_EXTENSIONS);
if (!in_array($type, $permitted)) {
form_set_error('taxonomy_image_external', t('The URL (@url) you entered does not point to a valid image file (@exts).', array(
'@url' => $url,
'@exts' => TAXONOMY_IMAGE_IMAGE_EXTENSIONS,
)));
}
}