function image_resize_filter_image_tag in Image Resize Filter 6
Same name and namespace in other branches
- 8 image_resize_filter.module \image_resize_filter_image_tag()
- 7 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 553 - image_resize_filter.module
Code
function image_resize_filter_image_tag($image = NULL, $settings = NULL) {
global $base_url;
$src = $image['destination'];
// Make the new file private if the original was private.
if (strpos($image['original'], 'system/files/') !== FALSE && variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
$src = file_create_url($src);
}
else {
$pieces = explode('/', $src);
foreach ($pieces as $part => $piece) {
$pieces[$part] = rawurlencode($piece);
}
$src = $base_url . '/' . implode('/', $pieces);
}
// 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);
}
$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', $image, $settings);
}