CKFinder 3 – PHP Connector Documentation
ResizedImageRepository Class Reference

Public Member Functions

 __construct (CKFinder $app)
 
 getResizedImage (ResourceType $sourceFileResourceType, string $sourceFileDir, string $sourceFileName, int $requestedWidth, int $requestedHeight)
 
 getExistingResizedImage (ResourceType $sourceFileResourceType, string $sourceFileDir, string $sourceFileName, string $thumbnailFileName)
 
 getContainer ()
 
 deleteResizedImages (ResourceType $sourceFileResourceType, string $sourceFilePath, string $sourceFileName)
 
 copyResizedImages (ResourceType $sourceFileResourceType, string $sourceFilePath, string $sourceFileName, ResourceType $targetFileResourceType, string $targetFilePath, string $targetFileName)
 
 renameResizedImages (ResourceType $sourceFileResourceType, string $sourceFilePath, string $originalSourceFileName, string $newSourceFileName)
 
 getResizedImagesList (ResourceType $sourceFileResourceType, string $sourceFilePath, string $sourceFileName, array $filterSizes=[])
 
 getResizedImageBySize (ResourceType $sourceFileResourceType, string $sourceFilePath, string $sourceFileName, int $width, int $height)
 

Protected Member Functions

 isSizeAllowedInConfig (int $width, int $height)
 
 getSizeNameFromConfig (int $width, int $height)
 
 createNodeValue ($resizedImage)
 
 sortImagesBySize (array $custom)
 

Protected Attributes

 $app
 
 $config
 
 $acl
 
 $dispatcher
 

Detailed Description

The ThumbnailRepository class.

A class responsible for resized image management that simplifies operations on resized versions of the image file, like batch renaming/moving together with the original file.

Member Function Documentation

◆ copyResizedImages()

copyResizedImages ( ResourceType  $sourceFileResourceType,
string  $sourceFilePath,
string  $sourceFileName,
ResourceType  $targetFileResourceType,
string  $targetFilePath,
string  $targetFileName 
)

Copies all resized images for a given file.

Exceptions
FilesystemException

◆ deleteResizedImages()

deleteResizedImages ( ResourceType  $sourceFileResourceType,
string  $sourceFilePath,
string  $sourceFileName 
)

Deletes all resized images for a given file.

Returns
bool true if deleted

◆ getExistingResizedImage()

getExistingResizedImage ( ResourceType  $sourceFileResourceType,
string  $sourceFileDir,
string  $sourceFileName,
string  $thumbnailFileName 
)

Returns an existing resized image.

Exceptions
FileNotFoundException
FilesystemException
Exception

◆ getResizedImage()

getResizedImage ( ResourceType  $sourceFileResourceType,
string  $sourceFileDir,
string  $sourceFileName,
int  $requestedWidth,
int  $requestedHeight 
)

Returns a resized image for the provided source file.

If an appropriate resized version already exists, it is reused.

Exceptions
FileNotFoundException
UnauthorizedException

◆ getResizedImageBySize()

getResizedImageBySize ( ResourceType  $sourceFileResourceType,
string  $sourceFilePath,
string  $sourceFileName,
int  $width,
int  $height 
)
Exceptions
FilesystemException
Exception

◆ getResizedImagesList()

getResizedImagesList ( ResourceType  $sourceFileResourceType,
string  $sourceFilePath,
string  $sourceFileName,
array  $filterSizes = [] 
)

Returns a list of resized images generated for a given file.

Parameters
ResourceType$sourceFileResourceTypesource file resource type
string$sourceFilePathsource file backend-relative path
string$sourceFileNamesource file name
array$filterSizesarray containing names of sizes defined in the images.sizes configuration
Exceptions
FilesystemException

◆ getSizeNameFromConfig()

getSizeNameFromConfig ( int  $width,
int  $height 
)
protected

Returns the size name defined in the configuration, where width or height are equal to those given in parameters.

Resized images keep the original image aspect ratio. When an image is resized using the size from the configuration, at least one of the borders has the same length.

◆ isSizeAllowedInConfig()

isSizeAllowedInConfig ( int  $width,
int  $height 
)
protected

Checks if the provided image size is allowed in the configuration.

This is checked when Permission::IMAGE_RESIZE_CUSTOM is not allowed in the source file folder.

Returns
bool true if the provided size is allowed in the configuration

◆ renameResizedImages()

renameResizedImages ( ResourceType  $sourceFileResourceType,
string  $sourceFilePath,
string  $originalSourceFileName,
string  $newSourceFileName 
)

Renames all resized images created for a given file.

Exceptions
FilesystemException

Member Data Documentation

◆ $dispatcher

$dispatcher
protected

Event dispatcher.


The documentation for this class was generated from the following file: