M
M
mts20502016-08-03 18:02:00
1C-Bitrix
mts2050, 2016-08-03 18:02:00

How to display images by link in Bitrix 1C?

Tell me what needs to be changed so that the output of the image comes from a third-party source, i.e. by reference. As far as I understand, it is necessary to create a string type property for each picture. Maybe it is possible to assign symbolic codes of the current properties to the image to these properties and then there will be no need to change anything in the code?
As far as I understand, you need to edit the code here:

/***DETAIL_PICTURE***/
if(is_array($arResult["DETAIL_PICTURE"])) {
    $arFileTmp = CFile::ResizeImageGet(
        $arResult["DETAIL_PICTURE"],
        array("width" => $arParams["DISPLAY_DETAIL_IMG_WIDTH"], "height" => $arParams["DISPLAY_DETAIL_IMG_HEIGHT"]),
        BX_RESIZE_IMAGE_PROPORTIONAL,
        true
    );

    $arResult["DETAIL_IMG"] = array(
        "SRC" => $arFileTmp["src"],
        "WIDTH" => $arFileTmp["width"],
        "HEIGHT" => $arFileTmp["height"],
    );

    $arFileTmp_prev = CFile::ResizeImageGet(
        $arResult["DETAIL_PICTURE"],
        array("width" => $arParams["DISPLAY_IMG_WIDTH"], "height" => $arParams["DISPLAY_IMG_HEIGHT"]),
        BX_RESIZE_IMAGE_PROPORTIONAL,
        true
    );

    $arResult["PREVIEW_IMG"] = array(
        "SRC" => $arFileTmp_prev["src"],
        "WIDTH" => $arFileTmp_prev["width"],
        "HEIGHT" => $arFileTmp_prev["height"],
    );
}

/***MORE_PICTURES_ALL***/
if(is_array($arResult["MORE_PHOTO"]) && count($arResult["MORE_PHOTO"]) > 0) {
    unset($arResult["DISPLAY_PROPERTIES"]["MORE_PHOTO"]);

    /***WATERMARK***/
    $detail_picture = CIBlock::GetArrayByID($arParams["IBLOCK_ID"], "FIELDS");
    $detail_picture = $detail_picture["DETAIL_PICTURE"]["DEFAULT_VALUE"];

    $arWaterMark = Array();

    if($detail_picture["USE_WATERMARK_FILE"] == "Y"):
        $arWaterMark[] = Array(
            "name" => "watermark",
            "position" => $detail_picture["WATERMARK_FILE_POSITION"] ? $detail_picture["WATERMARK_FILE_POSITION"] : "center",
            "size" => "real",
            "type" => "image",
            "alpha_level" => $detail_picture["WATERMARK_FILE_ALPHA"] ? $detail_picture["WATERMARK_FILE_ALPHA"] : 100,
            "file" => $_SERVER["DOCUMENT_ROOT"].$detail_picture["WATERMARK_FILE"],
            "fill" => "exact"
        );
    endif;

    if($detail_picture["USE_WATERMARK_TEXT"] == "Y"):
        $arWaterMark[] = Array(
            "name" => "watermark",
            "position" => $detail_picture["WATERMARK_TEXT_POSITION"] ? $detail_picture["WATERMARK_TEXT_POSITION"] : "center",
            "size" => "medium",
            "coefficient" => $detail_picture["WATERMARK_TEXT_SIZE"] ? $detail_picture["WATERMARK_TEXT_SIZE"] : 100,
            "type" => "text",
            "text" => $detail_picture["WATERMARK_TEXT"] ? $detail_picture["WATERMARK_TEXT"] : SITE_SERVER_NAME,
            "color" => $detail_picture["WATERMARK_TEXT_COLOR"] ? $detail_picture["WATERMARK_TEXT_COLOR"] : "000000",
            "font" => $detail_picture["WATERMARK_TEXT_FONT"] ? $_SERVER["DOCUMENT_ROOT"].$detail_picture["WATERMARK_TEXT_FONT"] : $_SERVER["DOCUMENT_ROOT"]."/bitrix/fonts/pt_sans-bold.ttf"
        );
    endif;

    /***MORE_PICTURES***/
    foreach($arResult["MORE_PHOTO"] as $key => $arFile) {
        if(!empty($arWaterMark)):
            $arFileTmp = CFile::ResizeImageGet(
                $arFile,
                array("width" => 10000, "height" => 10000),
                BX_RESIZE_IMAGE_PROPORTIONAL,
                true,
                $arWaterMark
            );

            $arResult["MORE_PHOTO"][$key] = array(
                "SRC" => $arFileTmp["src"],
                "WIDTH" => $arFileTmp["width"],
                "HEIGHT" => $arFileTmp["height"],
            );
        endif;

        $arFileTmp_prev = CFile::ResizeImageGet(
            $arFile,
            array("width" => $arParams["DISPLAY_MORE_PHOTO_WIDTH"], "height" => $arParams["DISPLAY_MORE_PHOTO_HEIGHT"]),
            BX_RESIZE_IMAGE_PROPORTIONAL,
            true
        );

        $arResult["MORE_PHOTO"][$key]["PREVIEW"] = array(
            "SRC" => $arFileTmp_prev["src"],
            "WIDTH" => $arFileTmp_prev["width"],
            "HEIGHT" => $arFileTmp_prev["height"],
        );
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question