c
This commit is contained in:
59
inc/Hura8/Components/Media/Controller/bMediaController.php
Normal file
59
inc/Hura8/Components/Media/Controller/bMediaController.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Hura8\Components\Media\Controller;
|
||||
|
||||
use Hura8\System\Controller\aAdminEntityBaseController;
|
||||
use Hura8\Components\Media\Model\MediaModel;
|
||||
use Hura8\System\Controller\aEntityBaseController;
|
||||
|
||||
|
||||
class bMediaController extends aEntityBaseController
|
||||
{
|
||||
static $image_folder = "media/lib";
|
||||
|
||||
static $resized_sizes = array(
|
||||
's' => ['width' => 300,]
|
||||
);
|
||||
|
||||
protected $objMediaModel;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->objMediaModel = new MediaModel();
|
||||
parent::__construct($this->objMediaModel);
|
||||
}
|
||||
|
||||
|
||||
protected function formatItemInList(array $item_info) : array
|
||||
{
|
||||
return $this->formatItemInfo($item_info);
|
||||
}
|
||||
|
||||
|
||||
protected function formatItemInfo(array $item_info) : ?array
|
||||
{
|
||||
if(!$item_info) return null;
|
||||
|
||||
$item_info['display_file'] = STATIC_DOMAIN . "/". static::$image_folder. "/". $item_info['file_url'];
|
||||
$item_info['image'] = ($item_info['file_type'] == 'image') ? self::getResizedImageCollection($item_info['file_url']) : null;
|
||||
|
||||
return $item_info;
|
||||
}
|
||||
|
||||
|
||||
public static function getResizedImageCollection($image_name) {
|
||||
$image = [];
|
||||
|
||||
$size_in_full = [
|
||||
's' => 'small' ,
|
||||
];
|
||||
|
||||
foreach (static::$resized_sizes as $size => $value) {
|
||||
$image[$size_in_full[$size]] = ($image_name) ? STATIC_DOMAIN . "/". static::$image_folder . "/". $size. IMAGE_FILE_SEPARATOR . $image_name : '';
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user