protected function ExifWidgetBase::retrieveImageFieldDefaultValue in Exif 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldWidget/ExifWidgetBase.php \Drupal\exif\Plugin\Field\FieldWidget\ExifWidgetBase::retrieveImageFieldDefaultValue()
Calculate default value for settings form.
More precisely, it calculate default value for image_field setting of widget.
simple implementation: Look for the first image field found.
Parameters
array $widget: Widget we are checking.
array $image_fields: Image fields links to this widget.
Return value
string First image field found or NULL if none.
1 call to ExifWidgetBase::retrieveImageFieldDefaultValue()
- ExifWidgetBase::settingsForm in src/
Plugin/ Field/ FieldWidget/ ExifWidgetBase.php - Returns a form to configure settings for the widget.
File
- src/
Plugin/ Field/ FieldWidget/ ExifWidgetBase.php, line 164
Class
- ExifWidgetBase
- Base class for 'Exif Field widget' plugin implementations.
Namespace
Drupal\exif\Plugin\Field\FieldWidgetCode
protected function retrieveImageFieldDefaultValue(array $widget, array $image_fields) {
if (array_key_exists('settings', $widget) && array_key_exists('image_field', $widget['settings'])) {
$result = $widget['settings']['image_field'];
}
else {
$result = NULL;
}
if (empty($result)) {
// Look for the first image field found.
$temp = array_keys($image_fields);
if (!empty($temp) && is_array($temp)) {
$result = $temp[0];
}
}
return $result;
}