exif_display.module in EXIF Custom 7
Primary hook implementations for the EXIF Display module.
File
exif_display/exif_display.moduleView source
<?php
/**
* @file
* Primary hook implementations for the EXIF Display module.
*/
/**
* Implements hook_field_extra_fields().
*/
function exif_display_field_extra_fields() {
$extra['file']['image']['form']['exif_display'] = array(
'label' => t('EXIF Display'),
'description' => t('A read-only display of all EXIF data available on this image.'),
'weight' => 2,
);
return $extra;
}
/**
* Implements hook_form_FORM_ID_alter() for file_entity_edit().
*/
function exif_display_form_file_entity_edit_alter(&$form, &$form_state, $form_id) {
// If there's no file entity, just bail.
if (empty($form['#entity'])) {
return;
}
// Load the data.
$data = exif_custom_get_exif_fields($form['#entity']->uri);
// If any data was found, display it in a simple table.
if (!empty($data)) {
$form['exif_display'] = array(
'#type' => 'table',
'#caption' => t('Available meta data for this image'),
'#header' => array(
t('Meta data field'),
t('Value'),
),
'#rows' => array(),
'#multiple' => FALSE,
'#js_select' => FALSE,
'#input' => FALSE,
'#element_validate' => array(
'exif_display_element_table_validate',
),
);
foreach ($data as $key => $val) {
if (is_array($val)) {
$val = implode(', ', $val);
}
$val = trim($val);
if (!empty($val) && $val !== '') {
$form['exif_display']['#rows'][] = array(
check_plain($key),
check_plain($val),
);
}
}
}
}
/**
* Callback for the table display for when using the Element module.
*/
function exif_display_element_table_validate() {
return TRUE;
}
Functions
Name | Description |
---|---|
exif_display_element_table_validate | Callback for the table display for when using the Element module. |
exif_display_field_extra_fields | Implements hook_field_extra_fields(). |
exif_display_form_file_entity_edit_alter | Implements hook_form_FORM_ID_alter() for file_entity_edit(). |