‪TYPO3CMS  10.4
TYPO3\CMS\Extbase\Service\ImageService Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Service\ImageService:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 __construct (EnvironmentService $environmentService=null, ResourceFactory $resourceFactory=null)
 
ProcessedFile applyProcessingInstructions ($image, array $processingInstructions)
 
string getImageUri (FileInterface $image, bool $absolute=false)
 
FileInterface File FileReference getImage (string $src, $image, bool $treatIdAsReference)
 

Protected Member Functions

FileInterface null getImageFromSourceString (string $src, bool $treatIdAsReference)
 
 setCompatibilityValues (ProcessedFile $processedImage)
 
array getCompatibilityImageResourceValues (ProcessedFile $processedImage)
 

Protected Attributes

ResourceFactory $resourceFactory
 
EnvironmentService $environmentService
 

Detailed Description

Service for processing images

Definition at line 34 of file ImageService.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Extbase\Service\ImageService::__construct ( EnvironmentService  $environmentService = null,
ResourceFactory  $resourceFactory = null 
)

ImageService constructor.

Parameters
EnvironmentService | null$environmentService
ResourceFactory | null$resourceFactory

Definition at line 50 of file ImageService.php.

References TYPO3\CMS\Extbase\Service\ImageService\$environmentService, and TYPO3\CMS\Extbase\Service\ImageService\$resourceFactory.

Member Function Documentation

◆ applyProcessingInstructions()

ProcessedFile TYPO3\CMS\Extbase\Service\ImageService::applyProcessingInstructions (   $image,
array  $processingInstructions 
)

Create a processed file

Parameters
FileInterface | FileReference$image
array$processingInstructions
Returns
‪ProcessedFile

Definition at line 63 of file ImageService.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\CONTEXT_IMAGECROPSCALEMASK, TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile(), TYPO3\CMS\Core\Resource\File\process(), and TYPO3\CMS\Extbase\Service\ImageService\setCompatibilityValues().

◆ getCompatibilityImageResourceValues()

array TYPO3\CMS\Extbase\Service\ImageService::getCompatibilityImageResourceValues ( ProcessedFile  $processedImage)
protected

Calculates the compatibility values This is duplicate code taken from ContentObjectRenderer::getImgResource() Ideally we should get rid of this code in both places.

Parameters
ProcessedFile$processedImage
Returns
‪array

Definition at line 245 of file ImageService.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getExtension(), TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile(), TYPO3\CMS\Core\Resource\ProcessedFile\getProperty(), and TYPO3\CMS\Core\Resource\ProcessedFile\getPublicUrl().

Referenced by TYPO3\CMS\Extbase\Service\ImageService\setCompatibilityValues().

◆ getImage()

FileInterface File FileReference TYPO3\CMS\Extbase\Service\ImageService::getImage ( string  $src,
  $image,
bool  $treatIdAsReference 
)

Get File or FileReference object

This method is a factory and compatibility method that does not belong to this service, but is put here for pragmatic reasons for the time being. It should be removed once we do not support string sources for images anymore.

Parameters
string$src
FileInterface | \TYPO3\CMS\Extbase\Domain\Model\FileReference | null$image
bool$treatIdAsReference
Returns
‪FileInterface|File|FileReference
Exceptions

Definition at line 131 of file ImageService.php.

References TYPO3\CMS\Extbase\Service\ImageService\getImageFromSourceString().

◆ getImageFromSourceString()

FileInterface null TYPO3\CMS\Extbase\Service\ImageService::getImageFromSourceString ( string  $src,
bool  $treatIdAsReference 
)
protected

Get File or FileReference object by src

Parameters
string$src
bool$treatIdAsReference
Returns
‪FileInterface|null

Definition at line 181 of file ImageService.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger().

Referenced by TYPO3\CMS\Extbase\Service\ImageService\getImage().

◆ getImageUri()

string TYPO3\CMS\Extbase\Service\ImageService::getImageUri ( FileInterface  $image,
bool  $absolute = false 
)

Get public url of image depending on the environment

Parameters
FileInterface$image
bool | false$absolute‪Force absolute URL
Returns
‪string

Definition at line 88 of file ImageService.php.

References $GLOBALS, and TYPO3\CMS\Core\Resource\FileInterface\getPublicUrl().

◆ setCompatibilityValues()

TYPO3\CMS\Extbase\Service\ImageService::setCompatibilityValues ( ProcessedFile  $processedImage)
protected

Set compatibility values to frontend controller object in case we are in frontend environment.

Parameters
ProcessedFile$processedImage

Definition at line 212 of file ImageService.php.

References $GLOBALS, TYPO3\CMS\Extbase\Service\ImageService\getCompatibilityImageResourceValues(), TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile(), and TYPO3\CMS\Core\Resource\ProcessedFile\getPublicUrl().

Referenced by TYPO3\CMS\Extbase\Service\ImageService\applyProcessingInstructions().

Member Data Documentation

◆ $environmentService

EnvironmentService TYPO3\CMS\Extbase\Service\ImageService::$environmentService
protected

Definition at line 42 of file ImageService.php.

Referenced by TYPO3\CMS\Extbase\Service\ImageService\__construct().

◆ $resourceFactory

ResourceFactory TYPO3\CMS\Extbase\Service\ImageService::$resourceFactory
protected

Definition at line 38 of file ImageService.php.

Referenced by TYPO3\CMS\Extbase\Service\ImageService\__construct().