PHP 클래스 Contao\Picture
The class resizes images and prepares data for the
element.
Usage:
$picture = new Picture(new File('example.jpg'));
$data = $picture
->setImportantPart(array('x'=>10, 'y'=>10, 'width'=>100, 'height'=>100))
->setImageSize(ImageSizeModel::findByPk(1))
->setImageSizeItems(ImageSizeItemModel::findVisibleByPid(1, array('order'=>'sorting ASC')))
->getTemplateData()
;
Shortcut
$data = Picture::create('example.jpg', 1)->getTemplateData();
$data = Picture::create('example.jpg', array(100, 100, 'crop'))->getTemplateData();
파일 보기
프로젝트 열기: contao/core-bundle
1 사용 예제들
보호된 프로퍼티들
프로퍼티 |
타입 |
설명 |
|
$image |
Image |
The Image instance of the source image |
|
$imageSize |
ImageSizeModel | object |
The image size |
|
$imageSizeItems |
ImageSizeItemModel[] | Collection |
The image size items collection |
|
공개 메소드들
메소드 |
설명 |
|
__construct ( contao\File $file ) |
Create a new object to handle a picture element |
|
create ( string | contao\File $file, array | integer $size = null ) : static |
Create a picture instance from the given image path and size |
|
getTemplateData ( ) : array |
Get the picture element definition array |
|
setImageSize ( ImageSizeModel | object $imageSize ) |
Set the image size |
|
setImageSizeItems ( ImageSizeItemModel[] | Collection $imageSizeItems ) |
Set the image size items collection |
|
setImportantPart ( array $importantPart = null ) |
Set the important part settings |
|
보호된 메소드들
메소드 |
설명 |
|
getConfigurationItem ( Model | object $imageSize ) : Contao\Image\PictureConfigurationItem |
Get the config for one picture source element |
|
메소드 상세
Create a new object to handle a picture element
public __construct ( contao\File $file ) |
$file |
contao\File |
A file instance of the source image |
Create a picture instance from the given image path and size
public static create ( string | contao\File $file, array | integer $size = null ) : static |
$file |
string | contao\File |
The image path or File instance |
$size |
array | integer |
The image size as array (width, height, resize mode) or an tl_image_size ID |
리턴 |
static |
The created picture instance |
getConfigurationItem()
보호된 메소드
Get the config for one picture source element
protected getConfigurationItem ( Model | object $imageSize ) : Contao\Image\PictureConfigurationItem |
$imageSize |
Model | object |
The image size or image size item model |
리턴 |
Contao\Image\PictureConfigurationItem |
|
Get the picture element definition array
setImageSizeItems()
공개 메소드
Set the image size items collection
public setImageSizeItems ( ImageSizeItemModel[] | Collection $imageSizeItems ) |
$imageSizeItems |
ImageSizeItemModel[] | Collection |
The image size items collection |
setImportantPart()
공개 메소드
Set the important part settings
프로퍼티 상세
The Image instance of the source image
protected Image,contao $image |
리턴 |
Image |
|
protected ImageSizeModel,contao|object $imageSize |
리턴 |
ImageSizeModel | object |
|
$imageSizeItems 보호되어 있는 프로퍼티
The image size items collection
protected ImageSizeItemModel[],contao|Collection,Contao\Model $imageSizeItems |
리턴 |
ImageSizeItemModel[] | Collection |
|