class Image extends Asset implements ImageInterface, VariantSupportInterface (View source)

An image

Traits

Trait for methods regarding the dimensions of an asset

Properties

protected PersistenceManagerInterface $persistenceManager from  Asset
protected LoggerInterface $systemLogger from  Asset
protected ResourceManager $resourceManager from  Asset
protected ThumbnailService $thumbnailService from  Asset
protected AssetService $assetService from  Asset
protected AssetRepository $assetRepository from  Asset
protected ImportedAssetRepository $importedAssetRepository from  Asset
protected DateTime $lastModified from  Asset
protected string $title from  Asset
protected string $caption from  Asset
protected string $copyrightNotice from  Asset
protected PersistentResource $resource from  Asset
protected Thumbnail> $thumbnails from  Asset
protected Tag> $tags from  Asset
protected AssetCollection> $assetCollections from  Asset
string $assetSourceIdentifier from  Asset
protected array $assetSourcesConfiguration from  Asset
protected AssetSourceInterface[] $assetSources from  Asset
protected int $width from  DimensionsTrait
protected int $height from  DimensionsTrait
protected ImageVariant> $variants
protected ImageService $imageService

Methods

__construct(PersistentResource $resource)

Constructor

void
initializeObject(int $initializationCause)

No description

void
initialize()

Override this to initialize upon instantiation.

from  Asset
string
getIdentifier()

No description

from  Asset
string
getLabel()

No description

from  Asset
getLastModified()

Returns the last modification timestamp for this asset

from  Asset
void
setResource(PersistentResource $resource)

Sets the asset resource and (re-)initializes the asset.

from  Asset
PersistentResource
getResource()

PersistentResource of the original file

from  Asset
string
getFileExtension()

Returns a file extension fitting to the media type of this asset

from  Asset
string
getMediaType()

Returns the IANA media type of this asset

from  Asset
void
setTitle(string $title)

Sets the title of this image (optional)

from  Asset
string
getTitle()

The title of this image

from  Asset
void
setCaption(string $caption)

Sets the caption of this asset (optional)

from  Asset
string
getCaption()

The caption of this asset

from  Asset
string
getCopyrightNotice()

No description

from  Asset
void
setCopyrightNotice(string $copyrightNotice)

No description

from  Asset
Collection
getTags()

Return the tags assigned to this asset

from  Asset
bool
addTag(Tag $tag)

Add a single tag to this asset

from  Asset
getThumbnail(int $maximumWidth = null, int $maximumHeight = null, string $ratioMode = ImageInterface::RATIOMODE_INSET, bool $allowUpScaling = null)

Returns a thumbnail of this asset

from  Asset
mixed
addThumbnail(Thumbnail $thumbnail)

An internal method which adds a thumbnail which was generated by the ThumbnailService.

from  Asset
void
refresh()

Calculates image width and height from the image resource.

void
setTags(Collection $tags)

Set the tags assigned to this asset

from  Asset
bool
removeTag(Tag $tag)

Remove a single tag from this asset

from  Asset
Collection
getAssetCollections()

Return the asset collections this asset is included in

from  Asset
void
setAssetCollections(Collection $assetCollections)

Set the asset collections that include this asset

from  Asset
void
setAssetSourceIdentifier(string $assetSourceIdentifier)

Set the asset source identifier for this asset

from  Asset
string|null
getAssetSourceIdentifier()

No description

from  Asset
AssetProxyInterface|null
getAssetProxy()

No description

from  Asset
bool
isInUse()

Returns true if the asset is still in use.

from  Asset
int
getUsageCount()

Returns the number of times the asset is in use.

from  Asset
int
getWidth()

Width of the image in pixels

int
getHeight()

Height of the image in pixels

bool
hasDimensions()

Does the asset have dimensions

float
getAspectRatio(bool $respectOrientation = false)

Edge / aspect ratio of the image

string
getOrientation()

Orientation of this image, i.e. portrait, landscape or square

bool
isOrientationSquare()

Whether this image is square aspect ratio and therefore has a square orientation

bool
isOrientationLandscape()

Whether this image is in landscape orientation

bool
isOrientationPortrait()

Whether this image is in portrait orientation

void
addVariant(ImageVariant $variant)

Adds a variant of this image

void
replaceVariant(ImageVariant $variant)

Replace a variant of this image, based on preset identifier and preset variant name.

array
getVariants()

Returns all variants (if any) derived from this asset

AssetVariantInterface|null
getVariant(string $presetIdentifier, string $presetVariantName)

Returns the variant identified by $presetIdentifier and $presetVariantName (if existing)

void
calculateDimensionsFromResource(PersistentResource $resource)

Calculates and sets the width and height of this Image asset based on the given PersistentResource.

Details

__construct(PersistentResource $resource)

Constructor

Parameters

PersistentResource $resource

Exceptions

Exception

void initializeObject(int $initializationCause)

No description

Parameters

int $initializationCause

Return Value

void

Exceptions

ImageFileException

protected void initialize()

Override this to initialize upon instantiation.

Return Value

void

string getIdentifier()

No description

Return Value

string

string getLabel()

No description

Return Value

string

DateTime getLastModified()

Returns the last modification timestamp for this asset

Return Value

DateTime

The date and time of last modification.

void setResource(PersistentResource $resource)

Sets the asset resource and (re-)initializes the asset.

Parameters

PersistentResource $resource

Return Value

void

PersistentResource getResource()

PersistentResource of the original file

Return Value

PersistentResource

string getFileExtension()

Returns a file extension fitting to the media type of this asset

Return Value

string

string getMediaType()

Returns the IANA media type of this asset

Return Value

string

void setTitle(string $title)

Sets the title of this image (optional)

Parameters

string $title

Return Value

void

string getTitle()

The title of this image

Return Value

string

Title of the asset

void setCaption(string $caption)

Sets the caption of this asset (optional)

Parameters

string $caption

Return Value

void

string getCaption()

The caption of this asset

Return Value

string

string getCopyrightNotice()

No description

Return Value

string

void setCopyrightNotice(string $copyrightNotice)

No description

Parameters

string $copyrightNotice

Return Value

void

Collection getTags()

Return the tags assigned to this asset

Return Value

Collection

bool addTag(Tag $tag)

Add a single tag to this asset

Parameters

Tag $tag

The tag to add

Return Value

bool

true if the tag added was new, false if it already existed

Thumbnail getThumbnail(int $maximumWidth = null, int $maximumHeight = null, string $ratioMode = ImageInterface::RATIOMODE_INSET, bool $allowUpScaling = null)

Returns a thumbnail of this asset

If the maximum width / height is not specified or exceeds the original asset's dimensions, the width / height of the original asset is used.

Parameters

int $maximumWidth

The thumbnail's maximum width in pixels

int $maximumHeight

The thumbnail's maximum height in pixels

string $ratioMode

Whether the resulting image should be cropped if both edge's sizes are supplied that would hurt the aspect ratio

bool $allowUpScaling

Whether the resulting image should be upscaled

Return Value

Thumbnail

Exceptions

Exception
Exception

mixed addThumbnail(Thumbnail $thumbnail)

An internal method which adds a thumbnail which was generated by the ThumbnailService.

Parameters

Thumbnail $thumbnail

Return Value

mixed

See also

getThumbnail()

void refresh()

Calculates image width and height from the image resource.

Return Value

void

Exceptions

ImageFileException

void setTags(Collection $tags)

Set the tags assigned to this asset

Parameters

Collection $tags

Return Value

void

bool removeTag(Tag $tag)

Remove a single tag from this asset

Parameters

Tag $tag

Return Value

bool

Collection getAssetCollections()

Return the asset collections this asset is included in

Return Value

Collection

void setAssetCollections(Collection $assetCollections)

Set the asset collections that include this asset

Parameters

Collection $assetCollections

Return Value

void

void setAssetSourceIdentifier(string $assetSourceIdentifier)

Set the asset source identifier for this asset

This is an internal method which allows Neos / Flow to keep track of assets which were imported from external asset sources.

Parameters

string $assetSourceIdentifier

Return Value

void

string|null getAssetSourceIdentifier()

No description

Return Value

string|null

AssetProxyInterface|null getAssetProxy()

No description

Return Value

AssetProxyInterface|null

bool isInUse()

Returns true if the asset is still in use.

Return Value

bool

int getUsageCount()

Returns the number of times the asset is in use.

Return Value

int

int getWidth()

Width of the image in pixels

Return Value

int

int getHeight()

Height of the image in pixels

Return Value

int

bool hasDimensions()

Does the asset have dimensions

Return Value

bool

float getAspectRatio(bool $respectOrientation = false)

Edge / aspect ratio of the image

Parameters

bool $respectOrientation

If false (the default), orientation is disregarded and always a value >= 1 is returned (like usual in "4 / 3" or "16 / 9")

Return Value

float

string getOrientation()

Orientation of this image, i.e. portrait, landscape or square

Return Value

string

One of this interface's ORIENTATION_* constants.

bool isOrientationSquare()

Whether this image is square aspect ratio and therefore has a square orientation

Return Value

bool

bool isOrientationLandscape()

Whether this image is in landscape orientation

Return Value

bool

bool isOrientationPortrait()

Whether this image is in portrait orientation

Return Value

bool

void addVariant(ImageVariant $variant)

Adds a variant of this image

Note that you should try to re-use variants if you need to adjust them, rather than creating a new variant for every change. Non-used variants will remain in the database and block resource disk space until they are removed explicitly or the original image is deleted.

Parameters

ImageVariant $variant

The new variant

Return Value

void

Exceptions

InvalidArgumentException

void replaceVariant(ImageVariant $variant)

Replace a variant of this image, based on preset identifier and preset variant name.

If the variant is not based on a preset, it is simply added.

Parameters

ImageVariant $variant

The new variant to replace an existing one

Return Value

void

Exceptions

InvalidArgumentException

array getVariants()

Returns all variants (if any) derived from this asset

Return Value

array

AssetVariantInterface|null getVariant(string $presetIdentifier, string $presetVariantName)

Returns the variant identified by $presetIdentifier and $presetVariantName (if existing)

Parameters

string $presetIdentifier
string $presetVariantName

Return Value

AssetVariantInterface|null

protected void calculateDimensionsFromResource(PersistentResource $resource)

Calculates and sets the width and height of this Image asset based on the given PersistentResource.

Parameters

PersistentResource $resource

Return Value

void

Exceptions

ImageFileException