• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/componenthelper.php
  • Класс: BitrixSocialnetworkComponentHelper
  • Вызов: ComponentHelper::getAttachmentsData
static function getAttachmentsData($valueList, $siteId = false): array
{
	$result = [];

	if (!Loader::includeModule('disk'))
	{
		return $result;
	}

	if (
		!$siteId
		|| (string)$siteId === ''
	)
	{
		$siteId = SITE_ID;
	}

	foreach ($valueList as $value)
	{
		$attachedObject = AttachedObject::loadById($value, [ 'OBJECT' ]);
		if(
			!$attachedObject
			|| !$attachedObject->getFile()
		)
		{
			continue;
		}

		$attachedObjectUrl = BitrixDiskUrlManager::getUrlUfController('show', [ 'attachedId' => $value ]);

		$result[$value] = [
			"ID" => $value,
			"OBJECT_ID" => $attachedObject->getFile()->getId(),
			"NAME" => $attachedObject->getFile()->getName(),
			"SIZE" => CFile::formatSize($attachedObject->getFile()->getSize()),
			"URL" => $attachedObjectUrl,
			"IS_IMAGE" => TypeFile::isImage($attachedObject->getFile())
		];
	}

	return $result;
}