PHP Class Xpressengine\Media\MediaManager

### app binding : xe.media 으로 바인딩 되어 있음 XeMedia Facade 로 접근이 가능 ### 미디어 파일 확인 및 캐스팅 php if (XeMedia::is($file)) { $media = XeMedia::make($file); } ### 섬네일 생성 * 지원되는 섬네일 생성 타입 - fit : 지정된 사이즈에 꽉차고 넘치는 영역은 무시 - letter : 지정된 사이즈안에 이미지가 모두 들어가도록 생성 - widen : 가로 기준으로 생성 - heighten : 세로 기준으로 생성 - stretch : 비율을 무시하고 지정된 사이즈로 변경 - spill : 지정된 사이즈에 꽉차고 넘치는 영역을 보존 - crop : 지정된 좌표로부터 지정된 사이즈만큼 잘라냄 php $thumbnails = XeMedia::createThumbnails($file, 'letter'); 두번째 인자로 타입을 전달하지 않으면 config 에 설정된 타입으로 생성 > crop 의 경우 별도의 좌표가 필요하기 때문에 자동 섬네일 생성 사용에 추천되지 않음 ### 원본 미디어를 통한 섬네일 반환 php $thumbnails = Image::getThumbnails($media);
Author: XE Developers ([email protected])
Show file Open project: xpressengine/xpressengine Class Usage Examples

Protected Properties

Property Type Description
$config array config data
$factory CommandFactory CommandFactory instance
$handlers Xpressengine\Media\Handlers\AbstractHandler[] media handlers
$storage Xpressengine\Storage\Storage Storage instance

Public Methods

Method Description
__construct ( Storage $storage, CommandFactory $factory, array $config ) Constructor
cast ( File $file ) : Media 파일을 미디어 타입으로 변환, 메타데이터는 생성하지 않음
createThumbnails ( Media $media, string | null $type = null ) : Illuminate\Database\Eloquent\Collection | Image[] 섬네일 생성
extend ( string $type, AbstractHandler $handler ) : void 미디어 핸들러를 추가, 변경하여 기능 확장
getDerives ( Media $media ) : Illuminate\Database\Eloquent\Collection | Media[] 동적으로 생성된 미디어 파일 반환
getFileType ( File $file ) : string | null 파일이 특정 미디어 타입과 매칭된다며 해당 타입 반환
getHandler ( string $type ) : AbstractHandler Returns handler
getHandlerByFile ( File $file ) : AbstractHandler Returns handler by storage File instance
getHandlerByMedia ( Media $media ) : AbstractHandler Returns handler by storage Media instance
is ( File $file ) : boolean 파일이 미디어 파일인지 확인
make ( File $file ) : Media 파일을 타입에 맞는 미디어 객체로 재생성하여 반환
metaRemove ( Media $media ) : void Meta data 삭제
remove ( Media $media ) : boolean 미디어 삭제

Method Details

__construct() public method

Constructor
public __construct ( Storage $storage, CommandFactory $factory, array $config )
$storage Xpressengine\Storage\Storage Storage instance
$factory CommandFactory CommandFactory instance
$config array config data

cast() public method

파일을 미디어 타입으로 변환, 메타데이터는 생성하지 않음
public cast ( File $file ) : Media
$file Xpressengine\Storage\File file instance
return Xpressengine\Media\Models\Media

createThumbnails() public method

섬네일 생성
public createThumbnails ( Media $media, string | null $type = null ) : Illuminate\Database\Eloquent\Collection | Image[]
$media Xpressengine\Media\Models\Media media instance
$type string | null 섬네일 생성 방식
return Illuminate\Database\Eloquent\Collection | Xpressengine\Media\Models\Image[]

extend() public method

is() method 를 통해 파일이 미디어 인지 판별할 수 있어야 하므로 각각의 handler 들은 활성화된 상태로 전달 받도록 함
public extend ( string $type, AbstractHandler $handler ) : void
$type string media type
$handler Xpressengine\Media\Handlers\AbstractHandler media handler
return void

getDerives() public method

동적으로 생성된 미디어 파일 반환
public getDerives ( Media $media ) : Illuminate\Database\Eloquent\Collection | Media[]
$media Xpressengine\Media\Models\Media media instance
return Illuminate\Database\Eloquent\Collection | Xpressengine\Media\Models\Media[]

getFileType() public method

파일이 특정 미디어 타입과 매칭된다며 해당 타입 반환
public getFileType ( File $file ) : string | null
$file Xpressengine\Storage\File file instance
return string | null

getHandler() public method

Returns handler
public getHandler ( string $type ) : AbstractHandler
$type string media type
return Xpressengine\Media\Handlers\AbstractHandler

getHandlerByFile() public method

Returns handler by storage File instance
public getHandlerByFile ( File $file ) : AbstractHandler
$file Xpressengine\Storage\File file instance
return Xpressengine\Media\Handlers\AbstractHandler

getHandlerByMedia() public method

Returns handler by storage Media instance
public getHandlerByMedia ( Media $media ) : AbstractHandler
$media Xpressengine\Media\Models\Media media instance
return Xpressengine\Media\Handlers\AbstractHandler

is() public method

파일이 미디어 파일인지 확인
public is ( File $file ) : boolean
$file Xpressengine\Storage\File file instance
return boolean

make() public method

파일을 타입에 맞는 미디어 객체로 재생성하여 반환
public make ( File $file ) : Media
$file Xpressengine\Storage\File file instance
return Xpressengine\Media\Models\Media

metaRemove() public method

Meta data 삭제
public metaRemove ( Media $media ) : void
$media Xpressengine\Media\Models\Media media instance
return void

remove() public method

미디어 삭제
public remove ( Media $media ) : boolean
$media Xpressengine\Media\Models\Media media instance
return boolean

Property Details

$config protected property

config data
protected array $config
return array

$factory protected property

CommandFactory instance
protected CommandFactory,Xpressengine\Media $factory
return CommandFactory

$handlers protected property

media handlers
protected AbstractHandler[],Xpressengine\Media\Handlers $handlers
return Xpressengine\Media\Handlers\AbstractHandler[]

$storage protected property

Storage instance
protected Storage,Xpressengine\Storage $storage
return Xpressengine\Storage\Storage