Image
class Image extends BaseCachedFile implements EventSubscriberInterface
Image management actions. This class handles image processing and caching.
Basically, images are stored outside of the web space (by default in local/media/images), and cached inside the web space (by default in web/local/images).
In the images caches directory, a subdirectory for images categories (eg. product, category, folder, etc.) is automatically created, and the cached image is created here. Plugin may use their own subdirectory as required.
The cached image name contains a hash of the processing options, and the original (normalized) name of the image.
A copy (or symbolic link, by default) of the original image is always created in the cache, so that the full resolution image is always available.
Various image processing options are available :
- resizing, with border, crop, or by keeping image aspect ratio
- rotation, in degrees, positive or negative
- background color, applyed to empty background when creating borders or rotating
- effects. The effects are applied in the specified order. The following effects are available:
- gamma:value : change the image Gamma to the specified value. Example: gamma:0.7
- grayscale or greyscale: switch image to grayscale
- colorize:color : apply a color mask to the image. Exemple: colorize:#ff2244
- negative : transform the image in its negative equivalent
- vflip or vertical_flip : vertical flip
- hflip or horizontal_flip : horizontal flip
If a problem occurs, an ImageException may be thrown.
Constants
EXACT_RATIO_WITH_BORDERS |
|
EXACT_RATIO_WITH_CROP |
|
KEEP_IMAGE_RATIO |
|
Methods
Toggle visibility for an object
Clear the file cache. Is a subdirectory is specified, only this directory is cleared.
Take care of saving a file in the database and file storage
Take care of updating file in the database and file storage
Deleting file in the database and in storage
No description
No description
Process image and write the result in the image cache.
{@inheritdoc}
Details
in
BaseAction at line 130
mixed
genericToggleVisibility(
ModelCriteria $query,
ToggleVisibilityEvent $event,
EventDispatcherInterface $dispatcher = null)
Toggle visibility for an object
in
BaseCachedFile at line 49
__construct(
FileManager $fileManager)
in
BaseCachedFile at line 66
clearCache(
CachedFileEvent $event)
Clear the file cache. Is a subdirectory is specified, only this directory is cleared.
If no directory is specified, the whole cache is cleared. Only files are deleted, directories will remain.
in
BaseCachedFile at line 199
saveFile(
FileCreateOrUpdateEvent $event)
Take care of saving a file in the database and file storage
in
BaseCachedFile at line 239
updateFile(
FileCreateOrUpdateEvent $event)
Take care of updating file in the database and file storage
in
BaseCachedFile at line 262
deleteFile(
FileDeleteEvent $event)
Deleting file in the database and in storage
in
BaseCachedFile at line 267
updatePosition(
UpdateFilePositionEvent $event, $eventName,
EventDispatcherInterface $dispatcher)
in
BaseCachedFile at line 272
toggleVisibility(
FileToggleVisibilityEvent $event, $eventName,
EventDispatcherInterface $dispatcher)
at line 97
processImage(
ImageEvent $event,
string $eventName,
EventDispatcherInterface $dispatcher)
Process image and write the result in the image cache.
If the image already exists in cache, the cache file is immediately returned, without any processing If the original (full resolution) image is required, create either a symbolic link with the original image in the cache dir, or copy it in the cache dir.
This method updates the cachefilepath and file_url attributes of the event
at line 402
static
getSubscribedEvents()
{@inheritdoc}