function image_resize_filter_image_tag in Image Resize Filter 7
Same name and namespace in other branches
- 8 image_resize_filter.module \image_resize_filter_image_tag()
- 6 image_resize_filter.module \image_resize_filter_image_tag()
Generate a themed image tag based on an image array.
Parameters
$image: An array containing image information and properties.
$settings: Settings for the input filter.
1 call to image_resize_filter_image_tag()
- image_resize_filter_process_images in ./
image_resize_filter.module - Processing function for image resize filter. Replace img src properties with a URL to a resized image.
File
- ./
image_resize_filter.module, line 571 - After adding to a text format, this filter will parse the contents of submitted content and automatically scale image files to match the set dimensions of img tags.
Code
function image_resize_filter_image_tag($image = NULL, $settings = NULL) {
$src = file_create_url($image['destination']);
// Strip the http:// from the path if the original did not include it.
if (!preg_match('/^http[s]?:\\/\\/' . preg_quote($_SERVER['HTTP_HOST']) . '/', $image['original'])) {
$src = preg_replace('/^http[s]?:\\/\\/' . preg_quote($_SERVER['HTTP_HOST']) . '/', '', $src);
}
// Restore any URL query.
if (isset($image['original_query'])) {
$src .= '?' . $image['original_query'];
$image['original'] .= '?' . $image['original_query'];
}
$image['attributes']['src'] = $src;
// Set the link properties if necessary.
$image['link'] = FALSE;
if ($image['resize'] && $settings['link'] && !$image['has_link']) {
$image['link'] = array();
$image['link']['attributes'] = array(
'href' => $image['original'],
);
if (!empty($settings['class'])) {
$image['link']['attributes']['class'] = $settings['class'];
}
if (!empty($settings['rel'])) {
$image['link']['attributes']['rel'] = $settings['rel'];
}
if (!empty($image['attributes']['title'])) {
$image['link']['attributes']['title'] = $image['attributes']['title'];
}
}
// Theme the output and return.
return theme('image_resize_filter_image', array(
'image' => $image,
'settings' => $settings,
));
}