diff --git a/flexslider/flexslider_fields/flexslider_fields.module b/flexslider/flexslider_fields/flexslider_fields.module
index fddc835..9185859 100644
--- a/flexslider/flexslider_fields/flexslider_fields.module
+++ b/flexslider/flexslider_fields/flexslider_fields.module
@@ -63,21 +64,19 @@ function flexslider_fields_field_formatter_settings_form($field, $instance, $vie
'#options' => $image_styles,
);
+ $form['caption'] = array(
+ '#title' => t('Caption source'),
+ '#type' => 'select',
+ '#options' => array(
+ 0 => t('None'),
+ 1 => t('Image title'),
+ 'alt' => t('Image ALT'),
+ ),
+ '#default_value' => $settings['caption'],
+ );
// If the image field doesn't have the Title field enabled, tell the user.
if ($instance['settings']['title_field'] == FALSE) {
- $form['caption'] = array(
- '#title' => t('Use image title as the caption'),
- '#type' => 'checkbox',
- '#disabled' => TRUE,
- '#description' => t('You need to enable the Title field for this image field to be able use it as a caption.', array('@url' => url('admin/structure/types/manage/' . $instance['bundle'] . '/fields/' . $instance['field_name'], array('fragment' => 'edit-instance-settings-title-field', 'query' => array('destination' => 'admin/structure/types/manage/' . $instance['bundle'] . '/display'))))),
- );
- }
- else {
- $form['caption'] = array(
- '#title' => t('Use image title as the caption'),
- '#type' => 'checkbox',
- '#default_value' => $settings['caption'],
- );
+ $form['caption']['#description'] = t('You may need to enable the Title or ALT field for this image field to be able use it as a caption.', array('@url' => url('admin/structure/types/manage/' . $instance['bundle'] . '/fields/' . $instance['field_name'], array('fragment' => 'edit-instance-settings-title-field', 'query' => array('destination' => 'admin/structure/types/manage/' . $instance['bundle'] . '/display')))));
}
return $form;
@@ -155,9 +154,12 @@ function flexslider_fields_field_formatter_view($entity_type, $entity, $field, $
}
// Check caption settings
- if ($display['settings']['caption']) {
+ if ($display['settings']['caption'] === 1) {
$item['caption'] = filter_xss($item['item']['title']);
}
+ else if ($display['settings']['caption'] === 'alt') {
+ $item['caption'] = filter_xss($item['item']['alt']);
+ }
$items[$key] = $item;
}