Download the PHP package massif/statamic-responsive-images without Composer

On this page you can find all versions of the php package massif/statamic-responsive-images. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package statamic-responsive-images

Responsive Images

A production-ready Statamic 6 addon that renders responsive <picture> elements from a single Antlers tag. Format negotiation (AVIF → WebP → fallback) is handled by the browser, intrinsic dimensions are always set to prevent CLS, and a tiny inline LQIP is rendered behind the image while it loads.

Srcset generation follows the next/image model: a pool of candidate widths built from device_sizesimage_sizes, capped at the source image's intrinsic width.

Requirements

Installation

The addon auto-registers via its service provider. Publish the config if you want to tweak defaults:

Quickstart

Output (simplified):

With an asset field:

Parameters

Param Type Description
src string|Asset Required. URL, assets::id, or Asset instance. Empty values render nothing.
alt string Alt text. Falls back to the asset's alt field. Missing alt is logged as a warning.
sizes string sizes attribute. Defaults to default_sizes from config.
widths array|csv Override the srcset pool. E.g. widths="400,800,1200".
ratio string Force an aspect ratio. Accepts 16/9 or 16:9. Drives crop height on every srcset entry.
width int Explicit intrinsic width.
height int Explicit intrinsic height.
fit string Glide fit mode. Defaults to glide.default_fit (crop_focal) when a ratio is set. Without a ratio, URLs use fit=contain so Glide scales proportionally.
class string Class for the outermost rendered element. Lands on the wrapper when figure or ratio_wrapper is used, otherwise on the <img>.
img_class string Class applied directly to the <img>. Merges with class when there's no wrapper.
loading string lazy (default), eager.
decoding string async (default), sync, auto.
fetchpriority string auto (default), high, low.
preload bool Push a <link rel="preload" as="image" …> for the top enabled format onto the Antlers head stack. Works out of the box — Statamic's default head partial already renders that stack. See Preload below.
quality int Override the quality for all formats on this render. Defaults to per-format quality from config.
formats csv|array Limit which formats are emitted. E.g. formats="webp,fallback". Valid entries: avif, webp, fallback.
blur int Glide blur passthrough.
brightness int Glide brightness passthrough (-100..100).
contrast int Glide contrast passthrough (-100..100).
sharpen int Glide sharpen passthrough (0..100).
gamma float Glide gamma passthrough.
pixelate int Glide pixelate passthrough.
filter string Glide filter passthrough (e.g. sepia, greyscale).
flip string Glide flip passthrough (h, v, both).
orient int|string Glide orient passthrough (exif value or 0/90/180/270).
bg string Glide background colour passthrough (hex, rgb, rgba).
placeholder bool Set false to disable the inline LQIP for this tag.
figure bool Wrap output in <figure>.
caption string|bool Caption text (only rendered in figure mode). When omitted, the figure auto-captions from the resolved alt text. Pass caption="false" to disable the auto-caption.
ratio_wrapper bool Wrap output in a <div style="aspect-ratio:…">.
sources array Art-direction sources. See below.

Classes

class targets the outermost rendered element. When you wrap the output in a <figure> or a ratio <div>, the class lands on that wrapper; otherwise it lands on the <img>. If you also pass img_class in the wrapperless case, both are merged on the <img>.

Captions

In figure mode, the tag auto-captions from the resolved alt text (which itself falls back to the asset's alt field). Explicit caption wins. Pass caption="false" to render a <figure> without a <figcaption>.

Focal point → object-position

When the source is a Statamic asset with a focal point set in the CP, the tag emits an inline object-position: x% y% on the <img> so CSS-cropped layouts (e.g. object-fit: cover on a fixed-aspect container) keep the subject in frame. This is on by default, is a no-op when no focal point is set, and costs nothing when the CSS doesn't use object-fit.

Tag alias

For brevity, the addon ships a short alias {{ pic }} alongside the canonical {{ responsive_image }}. Both tags share every behavior, parameter, and wildcard form:

The alias handle is configurable:

Wildcard form

Resolve src from the template context by field name:

The tag suffix (after the :) is read from $this->context, so any field, augmented asset, or template variable on the current scope is usable.

Preload

For above-the-fold images (LCP candidates), set preload="true":

The tag pushes a <link rel="preload" as="image" imagesrcset=… imagesizes=… type="image/avif" fetchpriority="high"> onto the Antlers head stack. Statamic's default head partial (vendor/statamic/cms/resources/views/partials/head.blade.php) already renders that stack, so preload works out of the box on a stock layout.

If you've replaced the default head partial with a fully custom one, make sure it still renders the stack:

When the stack is absent, Statamic silently discards the push — no error, but also no preload link in the output.

When preload="true" is set, the tag also:

Both auto-behaviors are togglable in config:

Format selection. The preload link targets the highest-priority enabled format (AVIF → WebP → fallback). Browsers that can't decode the format (e.g. older browsers on an AVIF link) skip the preload — safe, because type= is set.

Limitations.

SVG and GIF

SVG (image/svg+xml) and GIF (image/gif) sources skip the Glide pipeline entirely. The tag emits a plain <img> with the original URL, width/height from metadata when available, class, loading, decoding, and aria-hidden="true" when alt is empty. No <picture>, no srcset, no re-encoding — raster transforms would either produce meaningless output (SVG) or lose animation (GIF).

Glide passthrough params (blur, sharpen, etc.) are ignored for these sources.

Art direction

Pass an array of entries via the sources parameter. Each entry becomes its own block of <source> elements with the given media query. Entries earlier in the array win (the browser picks the first matching <source>).

Antlers limitation — sources must be a variable, not an inline literal. Antlers' expression parser chokes on inline array literals whose string values contain colons (e.g. (max-width: 768px)), so you cannot pass :sources="[{...}]" directly in a template. Build the array outside the template and pass it by name. The cleanest options:

  1. Blueprint field. Add a replicator or grid field called image_sources with src, media, sizes, and ratio subfields, then:

  2. Template variable via a view composer, augmenter, or controller. Share a hero_sources array from PHP and reference it the same way:

Each entry accepts src (required), media, sizes, and ratio. The last entry's src is used as the <img> fallback when no breakpoint matches.

Source inheritance. An art-direction source may omit src to reuse the parent image with a different crop, ratio, or focal point per breakpoint:

Config

config/responsive-images.php:

device_sizes vs image_sizes. Device sizes cover full-width images at common device breakpoints. Image sizes cover small images (thumbnails, icons). The final srcset pool is their union, deduped, sorted, and capped at the source image's intrinsic width — the browser then picks the best candidate based on sizes.

Format quality. AVIF defaults to 50, WebP to 75, fallback to 82. Lower values ship smaller bytes; tune per project.

Placeholder integration with daun/statamic-placeholders. If you install the daun/statamic-placeholders addon, its placeholder data (ThumbHash, BlurHash, or Average color — whichever you've configured on the asset's placeholder field) is auto-detected and used in preference to the built-in Glide LQIP. When the asset has no placeholder data or when src is a raw URL, we silently fall back to the Glide LQIP — output shape is unchanged (still a base64 data URI on background-image). Provider choice lives entirely in that addon; we don't expose a provider knob, since mismatching our override against the blueprint's placeholder_type would silently miss and fall back. Disable the integration by setting placeholder.statamic_placeholders.enabled to false.

Automatic format support detection

By default the addon only emits an <avif> or <webp> <source> when the active imaging driver (statamic.assets.image_manipulation.driver) can actually encode it, probed via Statamic's ImageValidator. This prevents broken images on servers whose GD/Imagick lacks a format — a <picture> element does not fall back when a <source> fails to load. Disable with formats.detect_support => false (e.g. when a transform-CDN serves formats your local driver can't).

The per-format formats.avif.enabled / formats.webp.enabled flags still apply and are ANDed with detection.

Skipping modern formats for small images

Set formats.min_width (default 0, disabled) to a pixel width below which AVIF/WebP are skipped in favor of the fallback — the modern-format overhead rarely pays off on tiny thumbnails. AVIF is additionally never emitted below libavif's hard 16px floor (this is always on; it fixes 0-byte AVIF variants at tall aspect ratios).

Placeholders

sizes="auto"

Lazy images get sizes="auto, …" prepended (WHATWG auto-sizes) so the browser derives the displayed size from layout; older browsers ignore the token. Disable with markup.auto_sizes => false.

Metadata stripping

strip_metadata => true (default false) strips EXIF/ICC/XMP/IPTC on encode. It is a global Glide manipulator affecting every image on the site and discards copyright/EXIF, so it is opt-in. Imagick only.

Performance notes

Caveats

License

MIT


All versions of statamic-responsive-images with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
statamic/cms Version ^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package massif/statamic-responsive-images contains the following files

Loading the files please wait ...