2022-08-11 09:16:15 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Img
|
|
|
|
{
|
|
|
|
// File paths for storing avatars, banners, etc.
|
|
|
|
// Пути к файлам для хранения аватарок, баннеров и т.д.
|
|
|
|
const PATH = [
|
|
|
|
'avatars' => '/uploads/users/avatars/',
|
|
|
|
'avatars_small' => '/uploads/users/avatars/small/',
|
2022-12-09 15:11:21 +01:00
|
|
|
|
2022-08-11 09:16:15 +02:00
|
|
|
'users_cover' => '/uploads/users/cover/',
|
|
|
|
'users_cover_small' => '/uploads/users/cover/small/',
|
|
|
|
|
2022-12-09 15:11:21 +01:00
|
|
|
'facets_logo' => '/uploads/facets/logos/',
|
2022-08-11 09:16:15 +02:00
|
|
|
'facets_logo_small' => '/uploads/facets/logos/small/',
|
|
|
|
'facets_cover' => '/uploads/facets/cover/',
|
|
|
|
'facets_cover_small' => '/uploads/facets/cover/small/',
|
2022-12-09 15:11:21 +01:00
|
|
|
|
2022-08-11 09:16:15 +02:00
|
|
|
'posts_content' => '/uploads/posts/content/',
|
|
|
|
'posts_cover' => '/uploads/posts/cover/',
|
|
|
|
'posts_thumb' => '/uploads/posts/thumbnails/',
|
2022-12-09 15:11:21 +01:00
|
|
|
|
2022-08-11 09:16:15 +02:00
|
|
|
'favicons' => '/uploads/favicons/',
|
|
|
|
'thumbs' => '/uploads/thumbs/'
|
|
|
|
];
|
2022-12-09 15:11:21 +01:00
|
|
|
|
2022-08-11 09:16:15 +02:00
|
|
|
// User's Cover art or thumbnails
|
|
|
|
public static function image($file, $alt, $style, $type, $size)
|
|
|
|
{
|
|
|
|
$img = ($size == 'small') ? self::PATH['facets_logo_small'] . $file : self::PATH['facets_logo'] . $file;
|
2022-12-09 15:11:21 +01:00
|
|
|
|
2022-08-11 09:16:15 +02:00
|
|
|
if ($type == 'post') {
|
|
|
|
$img = ($size == 'thumbnails') ? self::PATH['posts_thumb'] . $file : self::PATH['posts_cover'] . $file;
|
|
|
|
}
|
|
|
|
|
|
|
|
return '<img class="' . $style . '" src="' . $img . '" title="' . $alt . '" alt="' . $alt . '">';
|
|
|
|
}
|
2022-12-09 15:11:21 +01:00
|
|
|
|
2022-08-11 09:16:15 +02:00
|
|
|
// User avatars
|
|
|
|
public static function avatar($file, $alt, $style, $size)
|
|
|
|
{
|
|
|
|
$img = ($size == 'small') ? self::PATH['avatars_small'] . $file : self::PATH['avatars'] . $file;
|
|
|
|
|
|
|
|
return '<img class="' . $style . '" src="' . $img . '" title="' . $alt . '" alt="' . $alt . '">';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Icons, screenshots associated with the site
|
2023-05-22 05:13:10 +02:00
|
|
|
public static function website($type, $host, $css = '')
|
2022-08-11 09:16:15 +02:00
|
|
|
{
|
2023-05-22 05:13:10 +02:00
|
|
|
$path = ($type == 'thumb') ? self::PATH['thumbs'] : self::PATH['favicons'];
|
2022-12-09 15:11:21 +01:00
|
|
|
|
2023-05-22 05:13:10 +02:00
|
|
|
$itemprop = ($type == 'thumb') ? 'itemprop="image"' : '';
|
2022-12-09 15:11:21 +01:00
|
|
|
|
2023-05-22 05:13:10 +02:00
|
|
|
if (file_exists(HLEB_PUBLIC_DIR . $path . $host . '.png')) {
|
|
|
|
return '<img ' . $itemprop . ' class="' . $css . '" src="' . $path . $host . '.png" title="' . $host . '" alt="' . $host . '">';
|
2022-08-11 09:16:15 +02:00
|
|
|
}
|
|
|
|
|
2023-05-22 05:13:10 +02:00
|
|
|
return '<img class="mr5 ' . $css . '" src="' . $path . 'no-link.png" title="' . $host . '" alt="' . $host . '">';
|
2022-08-11 09:16:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cover of users, blog
|
|
|
|
public static function cover($file, $type)
|
|
|
|
{
|
|
|
|
return $type == 'blog' ? self::PATH['facets_cover'] . $file : self::PATH['users_cover'] . $file;
|
|
|
|
}
|
|
|
|
}
|