- Модуль: catalog
- Путь к файлу: ~/bitrix/modules/catalog/lib/component/baseform.php
- Класс: BitrixCatalogComponentBaseForm
- Вызов: BaseForm::getImagePropertyEditHtml
protected function getImagePropertyEditHtml(array $property, $value): string
{
$inputName = $this->getFilePropertyInputName($property);
if ($value && !is_array($value))
{
$value = [$value];
}
$fileValues = [];
if (!empty($value) && is_array($value))
{
foreach ($value as $valueItem)
{
if (is_array($valueItem))
{
$fileId = $valueItem['ID'];
}
else
{
$fileId = $valueItem;
}
$propName = str_replace('n#IND#', $fileId, $inputName);
$fileValues[$propName] = $fileId;
}
}
$fileType = $property['settings']['FILE_TYPE'] ?? null;
$fileParams = [
'name' => $inputName,
'id' => $inputName . '_' . random_int(1, 1000000),
'description' => $property['settings']['WITH_DESCRIPTION'] ?? 'Y',
'allowUpload' => $fileType ? 'F' : 'I',
'allowUploadExt' => $fileType,
'maxCount' => ($property['settings']['MULTIPLE'] ?? 'N') !== 'Y' ? 1 : null,
'upload' => true,
'medialib' => false,
'fileDialog' => true,
'cloud' => true,
];
return $this->getImageComponent([
'FILE_SETTINGS' => $fileParams,
'FILE_VALUES' => $fileValues,
'LOADER_PREVIEW' => $this->getImagePropertyViewHtml($value),
]);
}