You are here

function ml_image_nodeapi in Media Library 6

Implementation of hook_nodeapi()

File

ml_image/ml_image.module, line 42
Media Library Image module.

Code

function ml_image_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {

  // We keep a record of all imagefield submitted images to use later
  if ($op == 'presave' && module_exists('imagefield')) {
    $type = content_types($node->type);
    foreach ($type['fields'] as $field => $field_info) {
      if ($field_info['module'] == 'filefield' && $field_info['widget']['module'] == 'imagefield') {
        foreach ($node->{$field} as $item) {
          if ($item['fid'] && !ml_image_get_image($item['fid'])) {
            $metatags = new stdClass();
            $metatags->title = $item['data']['title'];
            $metatags->fid = $item['fid'];
            $metatags->source = 'imagefield';
            ml_image_save_metatags($metatags);
          }
        }
      }
    }
  }
}