function filefield_meta_filefield in FileField 5.2
Same name and namespace in other branches
- 6.2 filefield_meta/filefield_meta.module \filefield_meta_filefield()
File
- filefield_meta/
filefield_meta.module, line 46
Code
function filefield_meta_filefield($op, &$node, $field, &$file, &$form = NULL) {
$args = func_get_args();
switch ($op) {
case 'file_form':
$form['file_preview']['#value'] = '';
$form['url']['#value'] .= '<br />' . t('width: !w; height: !h; duration: !d', array(
'!w' => $file['width'],
'!h' => $file['height'],
'!d' => $file['duration'],
));
$form['width'] = array(
'#type' => 'hidden',
'#value' => $file['width'],
);
$form['height'] = array(
'#type' => 'hidden',
'#value' => $file['height'],
);
$form['duration'] = array(
'#type' => 'hidden',
'#value' => $file['duration'],
);
break;
case 'file_prepare':
filefield_meta($file);
return $file;
break;
case 'file_save':
db_query('INSERT INTO {filefield_meta} (fid, width, height, duration) VALUES (%d, %d, %d, %d)', $file['fid'], $file['width'], $file['height'], $file['duration']);
break;
case 'file_delete':
db_query('DELETE FROM {filefield_meta} WHERE fid = %d', $file['fid']);
break;
case 'file_load':
$meta = db_fetch_array(db_query('SELECT * FROM {filefield_meta} WHERE fid = %d', $file['fid']));
if ($meta) {
return $meta;
}
break;
}
}