public static function ImageItem::propertyDefinitions in Drupal 9
Same name and namespace in other branches
- 8 core/modules/image/src/Plugin/Field/FieldType/ImageItem.php \Drupal\image\Plugin\Field\FieldType\ImageItem::propertyDefinitions()
Defines field item properties.
Properties that are required to constitute a valid, non-empty item should be denoted with \Drupal\Core\TypedData\DataDefinition::setRequired().
Return value
\Drupal\Core\TypedData\DataDefinitionInterface[] An array of property definitions of contained properties, keyed by property name.
Overrides FileItem::propertyDefinitions
See also
\Drupal\Core\Field\BaseFieldDefinition
File
- core/
modules/ image/ src/ Plugin/ Field/ FieldType/ ImageItem.php, line 138
Class
- ImageItem
- Plugin implementation of the 'image' field type.
Namespace
Drupal\image\Plugin\Field\FieldTypeCode
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties = parent::propertyDefinitions($field_definition);
unset($properties['display']);
unset($properties['description']);
$properties['alt'] = DataDefinition::create('string')
->setLabel(t('Alternative text'))
->setDescription(t("Alternative image text, for the image's 'alt' attribute."));
$properties['title'] = DataDefinition::create('string')
->setLabel(t('Title'))
->setDescription(t("Image title text, for the image's 'title' attribute."));
$properties['width'] = DataDefinition::create('integer')
->setLabel(t('Width'))
->setDescription(t('The width of the image in pixels.'));
$properties['height'] = DataDefinition::create('integer')
->setLabel(t('Height'))
->setDescription(t('The height of the image in pixels.'));
return $properties;
}