Я создал пользовательскую форму из функции buildForm. В этой форме я хотел бы добавить поле изображения.
Я могу сделать это с помощью этого кода:
$form['main']['image'] = array(
'#type' => 'text_format',
'#title' => t('image'),
'#default_value' => array(10),
);
Я могу загрузить и удалить изображение из моей формы. Однако, когда я загружаю изображение, у меня нет этого предварительного просмотра. Я имею в виду, когда я создаю контент через пользовательский интерфейс Drupal. Я могу добавить предварительно настроенное поле «изображение». Когда я загружаю изображение через это поле «изображение», у меня есть предварительный просмотр изображения.
И здесь, когда я создаю элемент поля программно, у меня нет предварительного просмотра изображения, когда я загружаю ее. Как использовать API Drupal для предварительного просмотра изображения, когда я загружаю ее через поле «изображение»?