Custom Field Plugin With Image Field


I have been working on a custom field plugin with which the aim is to create a custom field to be used for content and will consist of a link field and a file field through which a thumb image is to be uploaded. I’m ok with the first part is i.e. the link field for which I have declared a uri data definition with a varchar storage schema and a url type for the form element. But I cannot (based on the available documentation) figure out the proper way to manage the file field. I have used a managed_field type as for the form element but cannot figure out what is the correct datatype and storage schema to use.

Edit: The documentation I have found deals with three parts,

  1. The field class where the propertyDefinitions method is overridden and the properties are defined (ex. $properties[‘link’] = DataDefinition::create(‘uri’)->setLabel(t(‘Video Link’));)

  2. Also in the field class where the schema method is overridden and the storage properties are defined (ex. $columns[‘link’] = [ ‘type’ => ‘varchar’, ‘length’ => 255, ];)

  3. the widget class where the formElement method is overridden to define the input form (ex. $element[‘link’] = [
    ‘#type’ => ‘url’,
    ‘#title’ => t(‘Link’),
    ‘#default_value’ => isset($items[$delta]->link) ? $items[$delta]->link : null,
    ‘#empty_value’ => ”,
    ‘#placeholder’ => t(‘Insert a url’),

what should the equivalent parts for an image/file field property be defined?

any input would be appreciated, thanks

قالب وردپرس