function emthumb_emfield_field_extra in Embedded Media Field 5
Same name and namespace in other branches
- 6.3 contrib/emthumb/emthumb.module \emthumb_emfield_field_extra()
- 6 contrib/emthumb/emthumb.module \emthumb_emfield_field_extra()
- 6.2 contrib/emthumb/emthumb.module \emthumb_emfield_field_extra()
File
- contrib/
emthumb/ emthumb.module, line 100
Code
function emthumb_emfield_field_extra($op, $node, $field, &$items, $teaser, $page) {
switch ($op) {
case 'submit':
case 'validate':
if ($field['multiple']) {
foreach ($items as $delta => $item) {
$items[$delta]['data'] = $list['provider'];
}
}
else {
$emthumb = array_pop($items);
if (empty($items)) {
array_push($items, $emthumb);
}
else {
$items[0]['data']['emthumb'] = $emthumb['emthumb']['emthumb'];
}
}
break;
// called after content.module loads default data.
case 'load':
//print_r($items);
$output = array();
if (count($items)) {
$values = array();
foreach ($items as $delta => $file) {
$items[$delta]['data']['emthumb'] = _emthumb_file_load($file['data']['emthumb']['fid']);
}
return array(
$field['field_name'] => $items,
);
}
break;
case 'rss item':
// different from load (and others) as it can be, and is, called within each $field individually
$output = array();
if (count($items)) {
$values = array();
foreach ($items as $delta => $file) {
$thumbnail = _emthumb_file_load($file['data']['emthumb']['fid']);
if (isset($thumbnail['filepath'])) {
$thumbnail['filepath'] = url($thumbnail['filepath'], NULL, NULL, TRUE);
$output[$delta]['thumbnail'] = $thumbnail;
}
}
}
return $output;
// called before content.module defaults.
case 'insert':
foreach ($items as $delta => $item) {
$items[$delta]['data']['emthumb'] = emthumb_file_insert($node, $items[$delta]['data']['emthumb'], $field);
}
break;
// called before content.module defaults.
case 'update':
foreach ($items as $delta => $item) {
$items[$delta]['data']['emthumb'] = emthumb_file_update($node, $items[$delta]['data']['emthumb'], $field);
/* // Remove non-existant files from node_field
if (empty($items[$delta])) {
unset($items[$delta]);
}*/
}
// Compact deltas.
$items = array_values($items);
break;
case 'delete':
foreach ($items as $delta => $item) {
_emthumb_file_delete($item['data']['emthumb'], $field['field_name']);
}
break;
}
}