public static function ImageStyleItem::generateSampleValue in Field Image Style 8
Generates placeholder field values.
Useful when populating site with placeholder content during site building or profiling.
Parameters
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.
Return value
array An associative array of values.
Overrides ListItemBase::generateSampleValue
File
- src/
Plugin/ Field/ FieldType/ ImageStyleItem.php, line 82
Class
- ImageStyleItem
- Plugin implementation of the 'image_style' field type.
Namespace
Drupal\field_image_style\Plugin\Field\FieldTypeCode
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
$allowed_options = $field_definition
->getFieldStorageDefinition()
->getSetting('allowed_values');
$values['value'] = array_rand($allowed_options);
return $values;
}