Quick start
-
Configure where images come from (a loader), what transforms them (a transformer), and optionally a placeholder:
config/packages/picasso.yaml picasso:loaders:filesystem:path: '%kernel.project_dir%/public/uploads'transformers:glide:sign_key: '%env(PICASSO_SIGN_KEY)%'placeholders:blur: { type: transformer } # optional: blurred preview while the image loadsWith a single loader and a single transformer, both are the defaults: no
default_loadernordefault_transformerto set. -
Import the routes, which serve the variants Glide renders:
config/routes/picasso.yaml picasso:resource: '@PicassoBundle/config/routes.php' -
Render an image:
<twig:Picasso:Imagesrc="photo.jpg"width="800"height="600"sizes="(max-width: 768px) 100vw, 800px"alt="A beautiful landscape"/>
What you get
Section titled “What you get”This is the HTML the bundle renders for it, with our 2400 × 1907 sample photo as src. It is unedited, except for the srcsets, shortened to three candidates each:
<picture> <source type="image/avif" srcset="/image/glide/filesystem/kittens.jpg?w=16&h=12&fm=avif&q=75&fit=contain&s=46b20b42f20d915f8ec3e1432c671407 16w, /image/glide/filesystem/kittens.jpg?w=32&h=24&fm=avif&q=75&fit=contain&s=5925887e7f4bef24b8631ea9e899baee 32w, … 13 more …, /image/glide/filesystem/kittens.jpg?w=2400&h=1800&fm=avif&q=75&fit=contain&s=c254c3f1acf603e01928f2d441600747 2400w" sizes="(max-width: 768px) 100vw, 800px" /> <source type="image/webp" srcset="/image/glide/filesystem/kittens.jpg?w=16&h=12&fm=webp&q=75&fit=contain&s=e989b07664edae30d55343d791ece953 16w, /image/glide/filesystem/kittens.jpg?w=32&h=24&fm=webp&q=75&fit=contain&s=c19133d9936568b0b1f9377c8d5e8309 32w, … 13 more …, /image/glide/filesystem/kittens.jpg?w=2400&h=1800&fm=webp&q=75&fit=contain&s=64cfe10861881cd4e1e6cc125ac0f5c2 2400w" sizes="(max-width: 768px) 100vw, 800px" /> <img src="/image/glide/filesystem/kittens.jpg?w=800&h=600&fm=jpg&q=75&fit=contain&s=23352685839c5cdfc3b40916fc0070b8" srcset="/image/glide/filesystem/kittens.jpg?w=16&h=12&fm=jpg&q=75&fit=contain&s=f19b82f5aeb4a9ce34f87645d2833e15 16w, /image/glide/filesystem/kittens.jpg?w=32&h=24&fm=jpg&q=75&fit=contain&s=e2031e15fcb041dba3bea64512d64538 32w, … 13 more …, /image/glide/filesystem/kittens.jpg?w=2400&h=1800&fm=jpg&q=75&fit=contain&s=e4bf323270b119b925249537bb353f55 2400w" sizes="(max-width: 768px) 100vw, 800px" width="800" height="600" loading="lazy" style="background-size:cover;background-position:center;background-repeat:no-repeat;background-image:url(/image/glide/filesystem/kittens.jpg?w=10&h=8&fm=jpg&q=30&fit=crop&blur=5&s=c4ef8a33d721337fb2319d4c278d5d1d);" onload="this.style.backgroundImage=''" alt="Three tabby kittens" /></picture>That single line of Twig is 50 signed URLs: 16 widths in each of the 3 formats, the fallback src and the placeholder. The largest candidate is 2144 px wide, not 3840: at the 4:3 ratio of width and height, a 1608 px high source gives at most 2144 px, and Picasso never upscales. Nothing is rendered yet. Glide renders a variant the first time a browser asks for it, then serves it from its cache:
- Browserpicks one candidate of the srcset
- /image/glide/…checks the signature
- Gliderenders on the first request only
- Cacheserves every next request
Next: choose the sizes that match your layout, and pick a placeholder.
