basilicom / thumbnail-bundle
This Bundle provides asynchronous thumbnail creation for Pimcore.
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 5
Forks: 6
Open Issues: 1
Type:pimcore-bundle
Requires
- ext-redis: ^4.3
- pimcore/pimcore: >=6.0 <7.0
- symfony/messenger: ^4.3
Requires (Dev)
- codeception/codeception: ^2.2
This package is auto-updated.
Last update: 2024-12-11 21:30:44 UTC
README
Enables asynchronous, worker based thumbnail creation.
Adding a lot of high resolution images to a Pimcore system can cause high load situations. This is mitigated by deferring thumbnail creation via jobs.
If a new asset is added to the system, the normal instant thumbnail generation is prevented and a default placeholder thumbnail is added instead. Simultaneously, a thumbnail creation job is added for the Symfony messenger component. Once the message is processed, the placeholder image is being replaced with the correct thumbnail.
License
GPLv3 - see: gpl-3.0.txt
Requirements
- Pimcore >= 6.0.0
- RabbitMQ if using the rabbitmq transport (for ampq on PHP 7.3 see: php-amqp/php-amqp#337)
- php-redis >= 4.3 if using the redis transport
- redis server >= 4.3 if using the redis transport (needs XREADGROUP support)
Installation
- Install the bundle using composer
composer require basilicom/thumbnail-bundle
. - Configure the bundle (see below)
- Execute
bin/console pimcore:bundle:enable BasilicomThumbnailBundle
.
Configuration
- As long as there is no patch preventing Pimcore from
generating system thumbnails, change
vendor/pimcore/pimcore/models/Asset/Image.php
, in methodupdate
the line$path = $this->getThumbnail(Image\Thumbnail\Config::getPreviewConfig())->getFileSystemPath();
to$path = $this->getThumbnail(Image\Thumbnail\Config::getPreviewConfig())->getFileSystemPath(true);
- Disable low quality preview generation:
# app/config/config.yml pimcore: assets: image: low_quality_image_preview: enabled: false
- Configure the Symfony Messenger (see https://symfony.com/doc/current/messenger.html).
# app/config/local/messenger.yaml framework: messenger: transports: #sample format: #async: "%env(MESSENGER_TRANSPORT_DSN)%" # sample redis transport, tested: async: "redis://redis:6379/messages" #doctrine does not work on pimcore, as only dbal is loaded, not doctrine! #async: "doctrine://default" # sample rabbitmq, tested: #async: "amqp://rabbitmq:rabbitmq@rabbitmq:5672/%2f/messages" routing: # async is whatever name you gave your transport above 'Basilicom\ThumbnailBundle\Message\ThumbnailJob': async # The bus that is going to be injected when injecting MessageBusInterface default_bus: command.bus buses: command.bus: middleware: - validation
- Process async messenges (jobs) via console
(or supervisord, see: https://symfony.com/doc/current/messenger.html)
add
-vv
to see individually processed messages
bin/console messenger:consume
Configure additional thumbnail formats
If there is a text property thumbnailConfig
on the asset
(possibly inherited from a parent folder) containing a
comma separated list of asset format names, thumbnails
for these formats are going to be generated, too.
Configure thumbnail placeholders
@todo not implemented, yet