function ImageItem::propertyDefinitions

Same name in other branches
  1. 9 core/modules/image/src/Plugin/Field/FieldType/ImageItem.php \Drupal\image\Plugin\Field\FieldType\ImageItem::propertyDefinitions()
  2. 8.9.x core/modules/image/src/Plugin/Field/FieldType/ImageItem.php \Drupal\image\Plugin\Field\FieldType\ImageItem::propertyDefinitions()
  3. 11.x core/modules/image/src/Plugin/Field/FieldType/ImageItem.php \Drupal\image\Plugin\Field\FieldType\ImageItem::propertyDefinitions()

Overrides FileItem::propertyDefinitions

File

core/modules/image/src/Plugin/Field/FieldType/ImageItem.php, line 150

Class

ImageItem
Plugin implementation of the 'image' field type.

Namespace

Drupal\image\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    $properties = parent::propertyDefinitions($field_definition);
    unset($properties['display']);
    unset($properties['description']);
    $properties['alt'] = DataDefinition::create('string')->setLabel(new TranslatableMarkup('Alternative text'))
        ->setDescription(new TranslatableMarkup("Alternative image text, for the image's 'alt' attribute."));
    $properties['title'] = DataDefinition::create('string')->setLabel(new TranslatableMarkup('Title'))
        ->setDescription(new TranslatableMarkup("Image title text, for the image's 'title' attribute."));
    $properties['width'] = DataDefinition::create('integer')->setLabel(new TranslatableMarkup('Width'))
        ->setDescription(new TranslatableMarkup('The width of the image in pixels.'));
    $properties['height'] = DataDefinition::create('integer')->setLabel(new TranslatableMarkup('Height'))
        ->setDescription(new TranslatableMarkup('The height of the image in pixels.'));
    return $properties;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.