PHP Class Uploadcare\File

Exibir arquivo Open project: uploadcare/uploadcare-php Class Usage Examples

Public Methods

Method Description
__construct ( string $uuid_or_url, Api $api, boolean | array | object $data = false ) Constructs an object for CDN file with specified ID
__get ( $name ) : array | null
__toString ( ) : string
copy ( string $target = null ) : File | string Copy the file.
copyTo ( string $target ) : string Copy the file to custom storage.
crop ( integer $width, integer $height, boolean $center = false, string | boolean $fill_color = false ) : File Get object with cropped parameters.
delete ( ) : array Delete file
effect ( string $effect ) : File Apply effect
getFileId ( ) : string Get UUID
getImgTag ( string $postfix = null, array $attribs = [] ) : string Get image tag
getUrl ( string $postfix = null ) : string Get url of original image
getUuid ( ) Get UUID
op ( string $operation ) : File Add any custom operation.
preview ( integer $width, integer $height ) : File Get object with preview parameters.
resize ( integer | boolean $width = false, integer | boolean $height = false ) : File Get object with resized parameters.
scaleCrop ( integer $width, integer $height, boolean $center = false ) : File Get object with cropped parameters.
store ( ) : array Store file.
updateInfo ( ) : array Update File info

Private Methods

Method Description
__addPartCenter ( array $part, array $params ) : array Adds part with center for operations
__addPartEffect ( array $part, string $effect ) : array Adds part with effect for operations
__addPartFillColor ( array $part, array $params ) : array Adds part with fill color for operations
__addPartSize ( array $part, array $params ) : array Adds part with size for operations

Method Details

__construct() public method

Constructs an object for CDN file with specified ID
public __construct ( string $uuid_or_url, Api $api, boolean | array | object $data = false )
$uuid_or_url string Uploadcare file UUID or CDN URL
$api Api Uploadcare class instance
$data boolean | array | object prepopulate this->cached_data

__get() public method

public __get ( $name ) : array | null
$name
return array | null

__toString() public method

public __toString ( ) : string
return string

copy() public method

Copy the file.
public copy ( string $target = null ) : File | string
$target string Name of custom storage.
return File | string

copyTo() public method

Copy the file to custom storage.
public copyTo ( string $target ) : string
$target string Name of custom storage.
return string

crop() public method

Get object with cropped parameters.
public crop ( integer $width, integer $height, boolean $center = false, string | boolean $fill_color = false ) : File
$width integer Crop width
$height integer Crop height
$center boolean Center crop? true or false (default false).
$fill_color string | boolean Fill color. If nothing is provided just use false (default false).
return File

delete() public method

Delete file
public delete ( ) : array
return array

effect() public method

Apply effect
public effect ( string $effect ) : File
$effect string Effect name
return File

getFileId() public method

Get UUID
Deprecation:
public getFileId ( ) : string
return string

getImgTag() public method

Get image tag
public getImgTag ( string $postfix = null, array $attribs = [] ) : string
$postfix string File path postfix
$attribs array additional attributes
return string

getUrl() public method

Get url of original image
public getUrl ( string $postfix = null ) : string
$postfix string
return string

getUuid() public method

Get UUID
public getUuid ( )

op() public method

Add any custom operation.
public op ( string $operation ) : File
$operation string
return File

preview() public method

Provide both width and height. If no width and height are provided exceptions will be thrown!
public preview ( integer $width, integer $height ) : File
$width integer Preview image width.
$height integer Preview image height.
return File

resize() public method

Provide width or height or both. If not width or height are provided exceptions will be thrown!
public resize ( integer | boolean $width = false, integer | boolean $height = false ) : File
$width integer | boolean Resized image width. Provide false if you resize proportionally.
$height integer | boolean Resized image height. Provide false if you resize proportionally.
return File

scaleCrop() public method

Get object with cropped parameters.
public scaleCrop ( integer $width, integer $height, boolean $center = false ) : File
$width integer Crop width
$height integer Crop height
$center boolean Center crop? true or false (default false).
return File

store() public method

Store file.
public store ( ) : array
return array

updateInfo() public method

Update File info
public updateInfo ( ) : array
return array