protected function ImageItem::defaultImageForm in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/image/src/Plugin/Field/FieldType/ImageItem.php \Drupal\image\Plugin\Field\FieldType\ImageItem::defaultImageForm()
Builds the default_image details element.
Parameters
array $element: The form associative array passed by reference.
array $settings: The field settings array.
2 calls to ImageItem::defaultImageForm()
- ImageItem::fieldSettingsForm in core/
modules/ image/ src/ Plugin/ Field/ FieldType/ ImageItem.php - Returns a form for the field-level settings.
- ImageItem::storageSettingsForm in core/
modules/ image/ src/ Plugin/ Field/ FieldType/ ImageItem.php - Returns a form for the storage-level settings.
File
- core/
modules/ image/ src/ Plugin/ Field/ FieldType/ ImageItem.php, line 407 - Contains \Drupal\image\Plugin\Field\FieldType\ImageItem.
Class
- ImageItem
- Plugin implementation of the 'image' field type.
Namespace
Drupal\image\Plugin\Field\FieldTypeCode
protected function defaultImageForm(array &$element, array $settings) {
$element['default_image'] = array(
'#type' => 'details',
'#title' => t('Default image'),
'#open' => TRUE,
);
// Convert the stored UUID to a FID.
$fids = [];
$uuid = $settings['default_image']['uuid'];
if ($uuid && ($file = $this
->getEntityManager()
->loadEntityByUuid('file', $uuid))) {
$fids[0] = $file
->id();
}
$element['default_image']['uuid'] = array(
'#type' => 'managed_file',
'#title' => t('Image'),
'#description' => t('Image to be shown if no image is uploaded.'),
'#default_value' => $fids,
'#upload_location' => $settings['uri_scheme'] . '://default_images/',
'#element_validate' => array(
'\\Drupal\\file\\Element\\ManagedFile::validateManagedFile',
array(
get_class($this),
'validateDefaultImageForm',
),
),
'#upload_validators' => $this
->getUploadValidators(),
);
$element['default_image']['alt'] = array(
'#type' => 'textfield',
'#title' => t('Alternative text'),
'#description' => t('This text will be used by screen readers, search engines, and when the image cannot be loaded.'),
'#default_value' => $settings['default_image']['alt'],
'#maxlength' => 512,
);
$element['default_image']['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#description' => t('The title attribute is used as a tooltip when the mouse hovers over the image.'),
'#default_value' => $settings['default_image']['title'],
'#maxlength' => 1024,
);
$element['default_image']['width'] = array(
'#type' => 'value',
'#value' => $settings['default_image']['width'],
);
$element['default_image']['height'] = array(
'#type' => 'value',
'#value' => $settings['default_image']['height'],
);
}