Vinoteca: модуль, шаблон и компоненты интернет-магазина вина на 1С-Битрикс

This commit is contained in:
jimagie committed 2026-10-22 03:32:28 +05:00
commit f6ba0d2174
470 files changed
+26454

No files matched your search

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Jinove\Vinoteca\Catalog;
use Bitrix\Iblock\ElementTable;
use Bitrix\Main\Loader;
final class Media
{
public static function thumbs(array $productIds, int $width, int $height): array
{
$productIds = array_values(array_unique(array_filter(array_map("intval", $productIds))));
if (!$productIds || !Loader::includeModule("iblock")) {
return [];
}
$images = [];
$rows = ElementTable::getList(["select" => ["ID", "PREVIEW_PICTURE", "DETAIL_PICTURE"], "filter" => ["=ID" => $productIds]]);
while ($row = $rows->fetch()) {
$fileId = (int)($row["DETAIL_PICTURE"] ?: $row["PREVIEW_PICTURE"]);
if ($fileId > 0) {
$resized = \CFile::ResizeImageGet($fileId, ["width" => $width, "height" => $height], BX_RESIZE_IMAGE_PROPORTIONAL, false);
if (!empty($resized["src"])) {
$images[(int)$row["ID"]] = (string)$resized["src"];
}
}
}
return $images;
}
}