function img_assist_load_image in Image Assist 5.3
Same name and namespace in other branches
- 5 img_assist.module \img_assist_load_image()
- 5.2 img_assist.module \img_assist_load_image()
- 6.2 img_assist.module \img_assist_load_image()
- 6 img_assist.module \img_assist_load_image()
Load an image from the database.
Related topics
1 call to img_assist_load_image()
- img_assist_render_image in ./
img_assist.module - Return image HTML.
File
- ./
img_assist.module, line 1966 - Image Assist module
Code
function img_assist_load_image($id, $derivatives = TRUE) {
$node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title, f.* FROM {files} f, {node} n WHERE f.nid = n.nid AND f.fid = %d'), $id));
$node->filepath = file_create_path($node->filepath);
if (!$derivatives) {
$dim = getimagesize($node->filepath, $info);
$node->width = $dim[0];
$node->height = $dim[1];
$image[$node->filename] = $node;
}
else {
$image_module_image = FALSE;
if (function_exists('image_get_sizes')) {
foreach (image_get_sizes() as $size) {
if ($size['label'] == $node->filename) {
$image_module_image = TRUE;
$result = db_query(db_rewrite_sql('SELECT n.nid, n.title, r.teaser, f.* FROM {files} f, {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = n.nid WHERE f.nid = n.nid AND n.nid = %d'), $node->nid);
while ($node = db_fetch_object($result)) {
$node->filepath = file_create_path($node->filepath);
$dim = getimagesize($node->filepath, $info);
$node->width = $dim[0];
$node->height = $dim[1];
$image[$node->filename] = $node;
}
break;
}
}
}
if (!$image_module_image) {
$dim = getimagesize($node->filepath, $info);
$node->width = $dim[0];
$node->height = $dim[1];
$image[IMAGE_THUMBNAIL] = $node;
$image[IMAGE_ORIGINAL] = $node;
}
}
return $image;
}