Image
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
Constructor
No description
Sets the asset resource and (re-)initializes the asset.
Returns a file extension fitting to the media type of this asset
Returns a thumbnail of this asset
An internal method which adds a thumbnail which was generated by the ThumbnailService.
Calculates image width and height from the image resource.
Set the asset collections that include this asset and keeps the attached variants' collections in sync.
Set the asset source identifier for this asset
Edge / aspect ratio of the image
Orientation of this image, i.e. portrait, landscape or square
Whether this image is square aspect ratio and therefore has a square orientation
Replace a variant of this image, based on preset identifier and preset variant name.
Returns all variants (if any) derived from this asset
Returns the variant identified by $presetIdentifier and $presetVariantName (if existing)
Calculates and sets the width and height of this Image asset based on the given PersistentResource.
Details
__construct(PersistentResource $resource)
Constructor
void
initializeObject(int $initializationCause)
No description
in
Asset at line 186
protected void
initialize()
Override this to initialize upon instantiation.
in
Asset at line 193
string
getIdentifier()
No description
in
Asset at line 201
string
getLabel()
No description
in
Asset at line 215
DateTime
getLastModified()
Returns the last modification timestamp for this asset
in
Asset at line 226
void
setResource(PersistentResource $resource)
Sets the asset resource and (re-)initializes the asset.
in
Asset at line 238
PersistentResource
getResource()
PersistentResource of the original file
in
Asset at line 248
string
getFileExtension()
Returns a file extension fitting to the media type of this asset
in
Asset at line 258
string
getMediaType()
Returns the IANA media type of this asset
in
Asset at line 269
void
setTitle(string $title)
Sets the title of this image (optional)
in
Asset at line 280
string
getTitle()
The title of this image
in
Asset at line 291
void
setCaption(string $caption)
Sets the caption of this asset (optional)
in
Asset at line 302
string
getCaption()
The caption of this asset
in
Asset at line 310
string
getCopyrightNotice()
No description
in
Asset at line 318
void
setCopyrightNotice(string $copyrightNotice)
No description
in
Asset at line 328
Collection
getTags()
Return the tags assigned to this asset
in
Asset at line 339
bool
addTag(Tag $tag)
Add a single tag to this asset
in
Asset at line 365
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.
in
Asset at line 378
mixed
addThumbnail(Thumbnail $thumbnail)
An internal method which adds a thumbnail which was generated by the ThumbnailService.
void
refresh()
Calculates image width and height from the image resource.
in
Asset at line 408
void
setTags(Collection $tags)
Set the tags assigned to this asset
in
Asset at line 420
bool
removeTag(Tag $tag)
Remove a single tag from this asset
in
Asset at line 437
Collection
getAssetCollections()
Return the asset collections this asset is included in
void
setAssetCollections(Collection $assetCollections)
Set the asset collections that include this asset and keeps the attached variants' collections in sync.
in
Asset at line 477
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.
in
Asset at line 485
string|null
getAssetSourceIdentifier()
No description
in
Asset at line 493
AssetProxyInterface|null
getAssetProxy()
No description
in
Asset at line 532
bool
isInUse()
Returns true if the asset is still in use.
in
Asset at line 543
int
getUsageCount()
Returns the number of times the asset is in use.
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
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.
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.
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)
protected void
calculateDimensionsFromResource(PersistentResource $resource)
Calculates and sets the width and height of this Image asset based on the given PersistentResource.