Same name and namespace in other branches
- 8.x-2.x src/Plugin/Field/FieldWidget/ExifWidgetBase.php \Drupal\exif\Plugin\Field\FieldWidget\ExifWidgetBase::retrieveImageFieldDefaultValue() 1 comment
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
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;
}