function emfield_widget_value in Embedded Media Field 7
Value callback for an emfield element.
Replace the file fid with a url.
1 string reference to 'emfield_widget_value'
- emfield_field_widget_form in ./
emfield.module - Implements hook_field_widget_form().
File
- ./
emfield.module, line 96
Code
function emfield_widget_value($element, $input = FALSE, $form_state) {
if ($input === FALSE) {
// We're building the displayed 'default value': expand the raw fid into
// "uri [fid:n]".
$fid = $element['#default_value'];
if (!empty($fid)) {
$q = db_select('file_managed', 'f');
$q
->addField('f', 'uri');
$q
->addTag('file_access')
->condition('f.fid', $fid['fid'])
->range(0, 1);
$result = $q
->execute();
// @todo If no result (file doesn't exist or no access).
$uri = $result
->fetchField();
return file_create_url($uri);
}
}
}