Как вывести изображение из пользовательского поля?

Var_dump компонента:
array(7) {
  ["bVarsFromForm"]=>
  bool(false)
  ["arUserField"]=>
  &array(23) {
    ["ID"]=>
    string(2) "17"
    ["ENTITY_ID"]=>
    string(4) "USER"
    ["FIELD_NAME"]=>
    string(17) "UF_PHOTOGALLERY[]"
    ["USER_TYPE_ID"]=>
    string(4) "file"
    ["XML_ID"]=>
    string(12) "PHOTOGALLERY"
    ["SORT"]=>
    string(3) "100"
    ["MULTIPLE"]=>
    string(1) "Y"
    ["MANDATORY"]=>
    string(1) "N"
    ["SHOW_FILTER"]=>
    string(1) "N"
    ["SHOW_IN_LIST"]=>
    string(1) "Y"
    ["EDIT_IN_LIST"]=>
    string(1) "Y"
    ["IS_SEARCHABLE"]=>
    string(1) "N"
    ["SETTINGS"]=>
    array(6) {
      ["SIZE"]=>
      int(20)
      ["LIST_WIDTH"]=>
      int(200)
      ["LIST_HEIGHT"]=>
      int(200)
      ["MAX_SHOW_SIZE"]=>
      int(0)
      ["MAX_ALLOWED_SIZE"]=>
      int(0)
      ["EXTENSIONS"]=>
      array(5) {
        ["jpg"]=>
        bool(true)
        ["gif"]=>
        bool(true)
        ["bmp"]=>
        bool(true)
        ["png"]=>
        bool(true)
        ["jpeg"]=>
        bool(true)
      }
    }
    ["EDIT_FORM_LABEL"]=>
    string(22) "Фотогалерея"
    ["LIST_COLUMN_LABEL"]=>
    string(0) ""
    ["LIST_FILTER_LABEL"]=>
    string(0) ""
    ["ERROR_MESSAGE"]=>
    string(0) ""
    ["HELP_MESSAGE"]=>
    string(0) ""
    ["USER_TYPE"]=>
    array(4) {
      ["USER_TYPE_ID"]=>
      string(4) "file"
      ["CLASS_NAME"]=>
      string(13) "CUserTypeFile"
      ["DESCRIPTION"]=>
      string(8) "Файл"
      ["BASE_TYPE"]=>
      string(4) "file"
    }
    ["VALUE"]=>
    array(2) {
      [0]=>
      int(1076)
      [1]=>
      int(1077)
    }
    ["ENTITY_VALUE_ID"]=>
    int(1)
    ["~EDIT_FORM_LABEL"]=>
    string(22) "Фотогалерея"
    ["~FIELD_NAME"]=>
    string(15) "UF_PHOTOGALLERY"
  }
  ["CACHE_TYPE"]=>
  string(1) "A"
  ["~bVarsFromForm"]=>
  bool(false)
  ["~arUserField"]=>
  array(22) {
    ["ID"]=>
    string(2) "17"
    ["ENTITY_ID"]=>
    string(4) "USER"
    ["FIELD_NAME"]=>
    string(15) "UF_PHOTOGALLERY"
    ["USER_TYPE_ID"]=>
    string(4) "file"
    ["XML_ID"]=>
    string(12) "PHOTOGALLERY"
    ["SORT"]=>
    string(3) "100"
    ["MULTIPLE"]=>
    string(1) "Y"
    ["MANDATORY"]=>
    string(1) "N"
    ["SHOW_FILTER"]=>
    string(1) "N"
    ["SHOW_IN_LIST"]=>
    string(1) "Y"
    ["EDIT_IN_LIST"]=>
    string(1) "Y"
    ["IS_SEARCHABLE"]=>
    string(1) "N"
    ["SETTINGS"]=>
    array(6) {
      ["SIZE"]=>
      int(20)
      ["LIST_WIDTH"]=>
      int(200)
      ["LIST_HEIGHT"]=>
      int(200)
      ["MAX_SHOW_SIZE"]=>
      int(0)
      ["MAX_ALLOWED_SIZE"]=>
      int(0)
      ["EXTENSIONS"]=>
      array(5) {
        ["jpg"]=>
        bool(true)
        ["gif"]=>
        bool(true)
        ["bmp"]=>
        bool(true)
        ["png"]=>
        bool(true)
        ["jpeg"]=>
        bool(true)
      }
    }
    ["EDIT_FORM_LABEL"]=>
    string(22) "Фотогалерея"
    ["LIST_COLUMN_LABEL"]=>
    string(0) ""
    ["LIST_FILTER_LABEL"]=>
    string(0) ""
    ["ERROR_MESSAGE"]=>
    string(0) ""
    ["HELP_MESSAGE"]=>
    string(0) ""
    ["USER_TYPE"]=>
    array(4) {
      ["USER_TYPE_ID"]=>
      string(4) "file"
      ["CLASS_NAME"]=>
      string(13) "CUserTypeFile"
      ["DESCRIPTION"]=>
      string(8) "Файл"
      ["BASE_TYPE"]=>
      string(4) "file"
    }
    ["VALUE"]=>
    array(2) {
      [0]=>
      int(1076)
      [1]=>
      int(1077)
    }
    ["ENTITY_VALUE_ID"]=>
    int(1)
    ["~EDIT_FORM_LABEL"]=>
    string(22) "Фотогалерея"
  }
  ["~CACHE_TYPE"]=>
  string(1) "A"
  ["form_name"]=>
  string(5) "form1"
}


В вардампе не вижу пути до изображения

Сам код компонента file
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();

echo "<pre>";var_dump($arParams);echo "</pre>";
foreach (GetModuleEvents("main", "system.field.edit.file", true) as $arEvent)
{
	if (ExecuteModuleEventEx($arEvent, array($arResult, $arParams)))
		return;
}

?>
<div id="main_<?=$arParams["arUserField"]["FIELD_NAME"]?>">
<?
$postFix = ($arParams["arUserField"]["MULTIPLE"] == "Y" ? "[]" : "");
foreach ($arResult["VALUE"] as $res):
	?>
	<div class="fields files">
		<input type="hidden" name="<?=$arParams["arUserField"]["~FIELD_NAME"]?>_old_id<?=$postFix?>" value="<?=$res?>" />
		<?=CFile::InputFile($arParams["arUserField"]["FIELD_NAME"], 0, $res, false, 0, "", "", 0, "", ' value="'.$res.'"', true, isset($arParams['SHOW_FILE_PATH']) ? $arParams['SHOW_FILE_PATH'] : true);?>
		<br>
<?
$arFile = CFile::GetFileArray($res);
if($arFile)
{
	if(CFile::IsImage($arFile["SRC"], $arFile["CONTENT_TYPE"]))
	{
		echo CFile::ShowImage(
			$arFile,
			isset($arParams["FILE_MAX_WIDTH"]) ? (int)$arParams["FILE_MAX_WIDTH"] : 0,
			isset($arParams["FILE_MAX_HEIGHT"]) ? (int)$arParams["FILE_MAX_HEIGHT"] : 0,
			null,
			'',
			false,
			0,
			0,
			0,
			!empty($arParams['FILE_URL_TEMPLATE']) ? $arParams['FILE_URL_TEMPLATE'] : ''
		);
	}
	else
	{
		if($arParams['FILE_URL_TEMPLATE'] <> '')
		{
			$src = CComponentEngine::MakePathFromTemplate($arParams['FILE_URL_TEMPLATE'], array('file_id' => $arFile["ID"]));
		}
		else
		{
			$src = $arFile["SRC"];
		}
		echo '<a href="'.htmlspecialcharsbx($src).'">'.htmlspecialcharsbx($arFile["FILE_NAME"]).'</a> ('.CFile::FormatSize($arFile["FILE_SIZE"]).')';
	}
}
?>
	</div>
	<?
endforeach;
?>
</div>
<?if ($arParams["arUserField"]["MULTIPLE"] == "Y" && $arParams["SHOW_BUTTON"] != "N"):?>
<div style="display:none" id="main_add_<?=$arParams["arUserField"]["FIELD_NAME"]?>" class="fields files">
	<input type="hidden" name="<?=$arParams["arUserField"]["~FIELD_NAME"]?>_old_id[]" value="" />
	<?=CFile::InputFile($arParams["arUserField"]["FIELD_NAME"], 0, "")?>
</div>
<input type="button" value="<?=GetMessage("USER_TYPE_PROP_ADD")?>" onClick="addElementFile('<?=$arParams["arUserField"]["FIELD_NAME"]?>', this)">
<?endif;?>
  • Вопрос задан
  • 376 просмотров
Решения вопроса 1
OlegMifle
@OlegMifle
php-программист
Битрикс хранит ID изображения. Используй CFile::GetPath();
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы