function image_insert in Image 6
Same name and namespace in other branches
- 5.2 image.module \image_insert()
- 5 image.module \image_insert()
Implementation of hook_insert().
File
- ./
image.module, line 534
Code
function image_insert($node) {
// If a new image node contains no new file, but has a translation source,
// insert all images from the source for this node.
if (empty($node->new_file) && !empty($node->translation_source)) {
db_query("INSERT INTO {image} (nid, fid, image_size) SELECT %d, fid, image_size FROM {image} WHERE nid = %d", $node->nid, $node->translation_source->nid);
return;
}
// Derivative images that aren't needed are set to the original file. Make
// note of the current path before calling _image_insert() because if it's
// in the temp directory it'll be moved. We'll need it later to determine
// which derivative images need to be saved with _image_insert().
$original_path = $node->images[IMAGE_ORIGINAL];
// Save the original first so that it if it's moved the derivatives are
// placed in the correct directory.
_image_insert($node, IMAGE_ORIGINAL, $original_path);
$sizes = image_get_derivative_sizes($node->images[IMAGE_ORIGINAL]);
foreach ($sizes as $key => $size_info) {
if (!empty($node->images[$key]) && $node->images[$key] != $original_path) {
_image_insert($node, $key, $node->images[$key]);
}
}
}