function _focal_point_form_append_focal_point_preview in Focal Point 7
Append the focal point preview field to file edit forms.
Parameters
array $form: The form array provided by hook_form_alter() to attach the focal point preview to.
object $file: The file object we should be adding the preview for.
2 calls to _focal_point_form_append_focal_point_preview()
- focal_point_form_file_entity_add_upload_alter in ./
focal_point.module - Implements hook_form_FORM_ID_alter().
- focal_point_form_file_entity_edit_alter in ./
focal_point.module - Implements hook_form_FORM_ID_alter().
File
- ./
focal_point.module, line 171
Code
function _focal_point_form_append_focal_point_preview(&$form, $file) {
if (_focal_point_supported_field_type('media') && is_object($file) && _focal_point_supported_file($file)) {
$default_value = !empty($file->focal_point) ? $file->focal_point : _focal_point_guess_default($file->fid);
$focal_point_id = drupal_html_id('focal-point-media');
$form['focal_point'] = array(
'#type' => 'container',
'#prefix' => '<label>' . t('Focal Point') . '</label>',
'indicator' => _focal_point_indicator($focal_point_id),
'thumbnail' => array(
'#type' => 'markup',
'#theme' => 'image_style',
'#style_name' => 'focal_point_preview',
'#path' => $file->uri,
'#alt' => isset($file->alt) ? $file->alt : '',
'#title' => isset($file->title) ? $file->title : '',
),
'preview_link' => _focal_point_preview_link($file->fid, $focal_point_id, $file->focal_point),
'focal_point' => _focal_point_field($focal_point_id, $default_value),
'focal_point_help' => _focal_point_help(),
);
// To prevent duplicate image previews from displaying we should go ahead
// and limit access to the preview element. Media does this already in some
// instances, but not all.
$form['preview']['#access'] = FALSE;
$form['#validate'][] = 'focal_point_form_validate';
}
}