ImageVariant
class ImageVariant extends Asset implements AssetVariantInterface, ImageInterface (View source)
A user defined variant (working copy) of an original Image asset
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 ImageService | $imageService | ||
protected Image | $originalAsset | ||
protected AbstractImageAdjustment> | $adjustments | ||
protected string | $name | ||
protected string | $presetIdentifier | ||
protected string | $presetVariantName |
Methods
Initialize this image variant
Setting the image resource on an ImageVariant is not allowed, this method will throw a RuntimeException.
Returns the resource of this image variant
File extension of the image without leading dot.
Setting the title on an ImageVariant is not allowed, this method will throw a RuntimeException.
Returns the title of the original image
Returns the caption of the original image
No description
Returns a thumbnail of this asset
An internal method which adds a thumbnail which was generated by the ThumbnailService.
Refreshes this image variant: according to the added adjustments, a new image is rendered and stored as this image variant's resource.
Set the tags assigned to this asset
Set the asset collections that include this asset
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
Returns the original image this variant is based on
Sets a name which can be used for identifying this variant
Returns the name
Retrieving variants from variants is not supported (no-operation)
Sets the identifier of the image variant preset which created this variant (if any)
Returns the identifier of the image variant preset which created this variant (if any)
No description
No description
Adds the given adjustment to the list of adjustments applied to this image variant.
Adds the given adjustments to the list of adjustments applied to this image variant.
Apply the given adjustment to the image variant.
No description
Tells the ImageService to render the resource of this ImageVariant according to the existing adjustments.
Details
__construct(Image $originalAsset)
Constructs a new Image Variant based on the given original
void
initializeObject(int $initializationCause)
Initialize this image variant
This method will generate the resource of this asset when this object has just been newly created. We can't run renderResource() in the constructor since not all dependencies have been injected then. Generating resources lazily in the getResource() method is not feasible either, because getters will be triggered by the validation mechanism on flushing the persistence which will result in undefined behavior.
We don't call refresh() here because we only want the resource to be rendered, not all other refresh actions from parent classes being executed.
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
void
setResource(PersistentResource $resource)
Setting the image resource on an ImageVariant is not allowed, this method will throw a RuntimeException.
PersistentResource
getResource()
Returns the resource of this image variant
string
getFileExtension()
File extension of the image without leading dot.
This will return the file extension of the original image as this should not be different in image variants
in
Asset at line 258
string
getMediaType()
Returns the IANA media type of this asset
void
setTitle(string $title)
Setting the title on an ImageVariant is not allowed, this method will throw a RuntimeException.
string
getTitle()
Returns the title of the original image
in
Asset at line 291
void
setCaption(string $caption)
Sets the caption of this asset (optional)
string
getCaption()
Returns the caption of the original image
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
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()
Refreshes this image variant: according to the added adjustments, a new image is rendered and stored as this image variant's resource.
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
in
Asset at line 448
void
setAssetCollections(Collection $assetCollections)
Set the asset collections that include this asset
in
Asset at line 476
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 484
string|null
getAssetSourceIdentifier()
No description
in
Asset at line 492
AssetProxyInterface|null
getAssetProxy()
No description
in
Asset at line 531
bool
isInUse()
Returns true if the asset is still in use.
in
Asset at line 542
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
AssetInterface
getOriginalAsset()
Returns the original image this variant is based on
void
setName(string $name)
Sets a name which can be used for identifying this variant
string
getName()
Returns the name
void
addVariant(ImageVariant $variant)
Adding variants to variants is not supported.
array
getVariants()
Retrieving variants from variants is not supported (no-operation)
void
setPresetIdentifier(string $presetIdentifier)
Sets the identifier of the image variant preset which created this variant (if any)
string|null
getPresetIdentifier()
Returns the identifier of the image variant preset which created this variant (if any)
void
setPresetVariantName(string $presetVariantName)
No description
string|null
getPresetVariantName()
No description
void
addAdjustment(ImageAdjustmentInterface $adjustment)
Adds the given adjustment to the list of adjustments applied to this image variant.
If an adjustment of the given type already exists, the existing one will be overridden by the new one.
void
addAdjustments(array $adjustments)
Adds the given adjustments to the list of adjustments applied to this image variant.
If an adjustment of one of the given types already exists, the existing one will be overridden by the new one.
protected void
applyAdjustment(ImageAdjustmentInterface $adjustment)
Apply the given adjustment to the image variant.
If an adjustment of the given type already exists, the existing one will be overridden by the new one.
Collection
getAdjustments()
No description
protected void
renderResource()
Tells the ImageService to render the resource of this ImageVariant according to the existing adjustments.