function img_assist_display in Image Assist 5.3
Same name and namespace in other branches
- 5 img_assist.module \img_assist_display()
- 5.2 img_assist.module \img_assist_display()
- 6.2 img_assist.module \img_assist_display()
- 6 img_assist.module \img_assist_display()
Create an IMG tag for an image.
This is nearly identical to image_display, but
- it uses a more efficient regenerate images routine
- the size attribute can be a custom size OR a standard size
Related topics
4 calls to img_assist_display()
- img_assist_popup in ./
img_assist.module - img_assist_properties_form in ./
img_assist.module - Construct the image properties form.
- img_assist_thumbs in ./
img_assist.module - Load the thumbnail display pane.
- theme_img_assist_inline in ./
img_assist.module
File
- ./
img_assist.module, line 1215 - Image Assist module
Code
function img_assist_display(&$node, $size = NULL, $attributes = array()) {
// Custom size should include values for label, width, and height.
if (is_array($size) && !empty($size['key']) && !empty($size['width']) && !empty($size['height'])) {
$label = $size['key'];
}
elseif ($size) {
// Size can be an array without the width and/or height.
if (is_array($size)) {
// Size is no longer an array.
$size = $size['key'];
}
$label = $size;
}
else {
$label = IMAGE_THUMBNAIL;
}
// Regenerate images if necessary.
$regen = FALSE;
if (!isset($node->images[$label])) {
$regen = TRUE;
}
elseif (!is_file(file_create_path($node->images[$label]))) {
$regen = TRUE;
}
elseif (filemtime(file_create_path($node->images[$label])) < variable_get('image_updated', 0)) {
$regen = TRUE;
}
else {
// If $size is not an array, try to find the corresponding predefined size.
// _image_build_derivatives() blindly assigns the *original* image file to
// all derivative image sizes that are smaller than the original image size.
// Without re-assigning the actual derivative size definition, img_assist
// would assume that this derivative size does not exist, delete the
// *original* file and subsequently fail to generate derivative images.
// Also, when one predefined size has changed, the derivative sizes need to
// be updated.
if (!is_array($size)) {
foreach (image_get_sizes() as $std_size) {
if (isset($std_size['key']) && $std_size['key'] == $label) {
$size = $std_size;
break;
}
}
}
if (is_array($size)) {
$info = image_get_info(file_create_path($node->images[$label]));
if ($info['width'] != $size['width'] && $info['height'] != $size['height']) {
$regen = TRUE;
}
}
}
if ($regen) {
_img_assist_build_derivatives($node, $size);
}
return image_display($node, $label);
}