Developer reference
Architecture
The extension has three entry points that share the same
Image service where applicable:
- ProcessingMiddleware intercepts frontend requests
matching the
/processed/path and delegates to Processor, which handles image optimization, format conversion, and caching. - OptimizeOnUploadListener reacts to PSR-14 file events
(
AfterandFile Added Event After) and delegates to ImageOptimizer for in-place lossless compression viaFile Replaced Event optipng/gifsicle/jpegoptim. - OptimizeImagesCommand and AnalyzeImagesCommand iterate the FAL index from the CLI, extending AbstractImageCommand for shared iteration and option parsing. See Usage.
SourceSetViewHelper generates responsive <img> markup
in Fluid templates. MaintenanceController provides the
backend module for statistics and cleanup.
Directory structure
-
-
-
AbstractImageCommand.php
-
AnalyzeImagesCommand.php
-
OptimizeImagesCommand.php
-
-
-
MaintenanceController.php
-
-
-
OptimizeOnUploadListener.php
-
-
-
ProcessingMiddleware.php
-
-
-
ImageOptimizer.php
-
SystemRequirementsService.php
-
-
Processor.php
-
-
SourceSetViewHelper.php
-
-
-
-
-
Modules.php
-
-
Icons.php
-
RequestMiddlewares.php
-
Services.yaml
-
Processing middleware
-
class
ProcessingMiddleware -
- Fully qualified name
-
\Netresearch\Nr Image Optimize\ Middleware\ Processing Middleware
Frontend middleware registered before
typo3/. Intercepts requests whose path starts withcms- frontend/ site /processed/and delegates image processing to the Processor class.
Processor
-
class
Processor -
- Fully qualified name
-
\Netresearch\Nr Image Optimize\ Processor
Core image processing engine. Parses the requested URL to extract dimensions, quality, mode, and format parameters. Uses the Intervention Image library for actual image manipulation. Processed images are cached on disk to avoid repeated processing.
SourceSetViewHelper
ImageOptimizer
-
class
ImageOptimizer -
- Fully qualified name
-
\Netresearch\Nr Image Optimize\ Service\ Image Optimizer
Shared service that shells out to
optipng,gifsicle, orjpegoptim(whichever is resolvable on the$PATH, or via theOPTIPNG_/BIN GIFSICLE_/BIN JPEGOPTIM_environment variables) viaBIN proc_with argument arrays. Used by both OptimizeOnUploadListener and OptimizeImagesCommand. A missing binary degrades gracefully -- that format is simply skipped.open
OptimizeOnUploadListener
-
class
OptimizeOnUploadListener -
- Fully qualified name
-
\Netresearch\Nr Image Optimize\ Event Listener\ Optimize On Upload Listener
PSR-14 listener for
AfterandFile Added Event After. Compresses newly uploaded/replaced files in place via ImageOptimizer, guarded against re-entrancy by storage UID + file identifier.File Replaced Event
Console commands
-
class
AbstractImageCommand -
- Fully qualified name
-
\Netresearch\Nr Image Optimize\ Command\ Abstract Image Command
Shared template method for both commands below: storage UID parsing, FAL index iteration, and progress rendering.
-
class
OptimizeImagesCommand -
- Fully qualified name
-
\Netresearch\Nr Image Optimize\ Command\ Optimize Images Command
Backs
nr:. See Usage.image: optimize
-
class
AnalyzeImagesCommand -
- Fully qualified name
-
\Netresearch\Nr Image Optimize\ Command\ Analyze Images Command
Backs
nr:. See Usage.image: analyze
Testing
composer ci:test
Individual test commands:
composer ci:test:php:cgl # Code style
composer ci:test:php:lint # PHP syntax
composer ci:test:php:phpstan # Static analysis
composer ci:test:php:unit # PHPUnit tests
composer ci:test:php:rector # Code quality