Skip to content

API Reference

Terse, lookup-oriented reference. For explanations and examples, follow the links into the Guide and Cookbook.

<twig:pgi:Image> component

Tito10047\ProgressiveImageBundle\Twig\Components\Image — full description in The Twig Component.

PropTypeDefault
src?stringnull
alt?stringnull
sizes?stringnull
ratio?stringnull
filter?stringnull
contextarray[]
pointInterest?string ("X0xY0")null
retina?boolbundle default
preloadboolfalse
prioritystring'high'
ttl?intbundle default

Variant Domain ports (Variant\Domain\Port\*)

InterfaceMethod(s)Built-in adapter
ImageManipulatorprocess(SourceImage, VariantSpec): GeneratedImageInterventionImageManipulator
PostProcessorsupports(OutputFormat): bool; process(GeneratedImage): GeneratedImageJpegoptim/Pngquant/Cwebp/AvifencPostProcessor
SourceReaderread(SourcePath): SourceImageResolverChainSourceReader
VariantStorageexists, write, read, delete, publicPath, writeFailMarker, failMarkerTimestampFlysystemVariantStorage
GenerationLockacquire(VariantId): ?Lock; release(Lock): voidSymfonyGenerationLock
Lock(opaque marker)SymfonyLock
Clocknow(): DateTimeImmutableSystemClock

Variant Application ports (Variant\Application\Port\*)

InterfaceMethod(s)Built-in adapter
GenerationDispatcherdispatch(GenerateVariant): voidSync/Terminate/MessengerGenerationDispatcher
DomainEventBuspublish(object): voidSymfonyDomainEventBus
OriginalUrlResolverresolve(SourcePath): stringDefaultOriginalUrlResolver
PendingUrlBuilderbuild(ResolveVariantUrl): stringQueryPendingUrlBuilder
UrlSignersign(string): string; check(string): boolSymfonyUriSigner

Rendering-context extension interfaces

InterfaceMethod(s)Config hook
UrlGenerator\ResponsiveImageUrlGeneratorInterfacegenerateUrl(path, targetW, targetH?, pointInterest?, context?): stringresponsive_strategy.generator
Modifier\ModifierInterfacesupports(string): bool; modify(string, array): arrayautoconfigured → tag progressive_image.modifier
Modifier\FilterModifierInterfacesupports(string): bool; modify(string, array): arrayautoconfigured → tag pgi.filter_modifier (currently unconsumed)
Decorators\PathDecoratorInterfacedecorate(path, context?): string; getSize(path, context?): array|nullpath_decorators (explicit service id list)

Domain model (Variant\Domain\Model\*)

TypeShape
Variantaggregate: id, source, spec, stateVariant::request(), startGenerating(), markReady(), markFailed()
VariantIdwraps a base64url HMAC-SHA256 string
VariantSpec{filters: FilterChain, format: OutputFormat, quality: Quality}
VariantPathVariantPath::for(VariantId, SourcePath, OutputFormat): self{format}/{shard}/{id}/{source}.{ext}
SourcePath / SourceImagelogical source path / already-read {stream, dimensions, mime}
GeneratedImage{contents: string, format: OutputFormat}
Dimensions{width: int, height: int}
CropBox{startX, startY, size: Dimensions}
PointOfInterest{x: int, y: int} (non-negative)
OutputFormatenum: Jpeg, Png, Webp, Avif
Qualitywraps an int

Filters (Variant\Domain\Filter\*)

All implement Filter { canonical(): array } and compose into an immutable FilterChain. See Filters, Formats & Quality for the raw-config shape each maps from.

Crop, Resize, Rotate, Background, Watermark (+ WatermarkPosition enum), Thumbnail (+ ThumbnailMode enum: Inset, Outbound).

Domain events

Published via DomainEventBus::publish() from GenerateVariantHandler:

  • VariantRequested
  • VariantGenerated
  • VariantGenerationFailed

Console command

bash
php bin/console progressive-image:generate-custom-css [path=assets/styles]

Generates responsive CSS custom properties from responsive_strategy.grid — see Responsive Grid & Ratios.

Routes

NamePathMethodPurpose
pgi_variant_serve/media/pgi/waitGETSigned endpoint used by fallback_while_pending: wait; see Generation Strategies.

Import via:

yaml
progressive_image:
    resource: "@ProgressiveImageBundle/config/routes.php"

Released under the MIT License.