function img_assist_map_save in Image Assist 5
Same name and namespace in other branches
- 5.3 img_assist.module \img_assist_map_save()
- 5.2 img_assist.module \img_assist_map_save()
- 6.2 img_assist.module \img_assist_map_save()
- 6 img_assist.module \img_assist_map_save()
Update the map table
Look for any images linked in this content and keep a reference of them.
Related topics
1 call to img_assist_map_save()
- img_assist_nodeapi in ./
img_assist.module - Implementation of hook_nodeapi().
File
- ./
img_assist.module, line 1427 - Image Assist module
Code
function img_assist_map_save($node) {
$content = $node->body;
// If CCK is used, image macros can be found in fields other than the body.
// Get all the fields that use text filtering and extract their content:
if (function_exists('content_types')) {
$type = content_types($node->type);
if (!empty($type['fields'])) {
foreach ($type['fields'] as $field) {
// Distinguish between plain text fields and filtered fields:
if (!empty($field['text_processing'])) {
if (count($node->{$field['field_name']})) {
foreach ($node->{$field['field_name']} as $field_instance) {
$content .= $field_instance['value'];
}
}
}
}
}
}
// Get all the macros from the content:
$macros = (array) img_assist_get_macros($content);
// Save the image references:
db_query('DELETE FROM {img_assist_map} WHERE nid = %d', $node->nid);
$nids = array();
foreach ($macros as $m) {
if (!isset($nids[$m['nid']]) && is_numeric($m['nid'])) {
db_query('INSERT INTO {img_assist_map} (nid, iid) VALUES(%d, %d)', $node->nid, $m['nid']);
$nids[$m['nid']] = $m['nid'];
}
}
}