Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
file.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Integration\Main
;
4
5
class
File
6
{
7
public
static
function
getFileSource
(
8
int
$fileId,
9
int
$width = 50,
10
int
$height = 50,
11
bool
$immediate =
false
12
): string
13
{
14
if
($fileId <= 0)
15
{
16
return
''
;
17
}
18
19
if
($file = \CFile::GetFileArray($fileId))
20
{
21
$fileInfo = \CFile::ResizeImageGet(
22
$file,
23
[
24
'width'
=> $width,
25
'height'
=> $height,
26
],
27
BX_RESIZE_IMAGE_EXACT,
28
false
,
29
false
,
30
$immediate
31
);
32
33
return
$fileInfo[
'src'
];
34
}
35
36
return
''
;
37
}
38
39
public
static
function
getFilesSources
(
40
array $fileIds,
41
int
$width = 50,
42
int
$height = 50,
43
bool
$immediate =
false
44
): array
45
{
46
if
(empty($fileIds))
47
{
48
return
[];
49
}
50
51
$filesSources = array_fill_keys($fileIds,
''
);
52
53
$res = \CFile::GetList([], [
'@ID'
=> implode(
','
, $fileIds)]);
54
while
($file = $res->Fetch())
55
{
56
$fileInfo = \CFile::ResizeImageGet(
57
$file,
58
[
59
'width'
=> $width,
60
'height'
=> $height,
61
],
62
BX_RESIZE_IMAGE_EXACT,
63
false
,
64
false
,
65
$immediate
66
);
67
68
$filesSources[$file[
'ID'
]] = $fileInfo[
'src'
];
69
}
70
71
return
$filesSources;
72
}
73
}
Bitrix\Socialnetwork\Integration\Main\File
Definition
file.php:6
Bitrix\Socialnetwork\Integration\Main\File\getFilesSources
static getFilesSources(array $fileIds, int $width=50, int $height=50, bool $immediate=false)
Definition
file.php:39
Bitrix\Socialnetwork\Integration\Main\File\getFileSource
static getFileSource(int $fileId, int $width=50, int $height=50, bool $immediate=false)
Definition
file.php:7
Bitrix\Socialnetwork\Integration\Main
Definition
file.php:3
modules
socialnetwork
lib
integration
main
file.php
Создано системой
1.10.0