legrisch/statamic-graphql-responsive-images
A Statamic GraphQL addon for querying responsive image sets in headless builds. It bridges Statamic’s image transformations with GraphQL so front ends can request breakpoint-ready sources and render optimized, responsive images without extra plumbing.
composer require legrisch/statamic-graphql-responsive-images. The package depends on Statamic’s GraphQL addon, so make sure statamic/graphql is installed and your GraphQL endpoint is working before wiring up the responsive image field.src/. The addon is primarily a thin adapter between the Responsive Images fieldtype and GraphQL, so the schema is the main contract you need to understand.src, srcset, sizes, and dimensions, then render the strings directly in an <img> tag.query Page($slug: String!) {
entry(slug: $slug) {
title
hero: responsiveImage(field: "hero_image") {
src
srcset
sizes
width
height
}
}
}
hero: ..., thumbnail: ...) so the response shape stays readable and frontend mapping remains explicit.@include(if: $withImages) or separate list/detail queries when you only need image data on detail pages. srcset strings can be large, and GraphQL will still transfer the whole string even if the frontend only uses src.srcset and sizes as opaque strings produced by the fieldtype. Pass them through to <img> and keep src as the fallback; do not try to parse or reconstruct them unless you have a specific art-direction requirement.<picture> or art-direction layouts, model each image as its own field/alias rather than trying to infer breakpoint variants from a single srcset string.site argument and verify that asset URLs resolve to the expected domain or path. Do not assume the default site’s URLs are valid everywhere.null image data. Keep responsive image fields nullable in your schema and guard for nulls in frontend components.src/srcset object.Asset type (url, width, height). Use aliases or distinct field names in your schema to keep the frontend mapping unambiguous.srcset in broad list queries unless the UI needs it; the payload can grow quickly across many entries.How can I help you explore Laravel packages today?