{"id":19324856,"url":"https://github.com/spatie/statamic-responsive-images","last_synced_at":"2025-05-15T18:04:18.893Z","repository":{"id":39802368,"uuid":"230652936","full_name":"spatie/statamic-responsive-images","owner":"spatie","description":"Responsive images for Statamic 3","archived":false,"fork":false,"pushed_at":"2025-02-24T09:16:14.000Z","size":8406,"stargazers_count":109,"open_issues_count":3,"forks_count":31,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-31T23:33:40.533Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-28T19:09:23.000Z","updated_at":"2025-03-17T02:06:51.000Z","dependencies_parsed_at":"2024-06-18T18:17:09.196Z","dependency_job_id":"2565a5a5-7a3d-466b-8a79-7938439f0c5f","html_url":"https://github.com/spatie/statamic-responsive-images","commit_stats":{"total_commits":260,"total_committers":26,"mean_commits":10.0,"dds":"0.46923076923076923","last_synced_commit":"7eb28c9bffcedd0ae46f130f5c0770549f745a0c"},"previous_names":[],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fstatamic-responsive-images","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fstatamic-responsive-images/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fstatamic-responsive-images/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fstatamic-responsive-images/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/statamic-responsive-images/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247755557,"owners_count":20990620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-11-10T02:07:09.571Z","updated_at":"2025-04-08T00:34:52.152Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/support-ukraine.svg?t=1\" /\u003e](https://supportukrainenow.org)\n\n\u003c!-- statamic:hide --\u003e\n[![Latest Version](https://img.shields.io/github/release/spatie/statamic-responsive-images.svg?style=flat-square)](https://github.com/spatie/statamic-responsive-images/releases)\n![Statamic 4.0+](https://img.shields.io/badge/Statamic-4.0+-FF269E?style=flat-square\u0026link=https://statamic.com)\n\n# Responsive Images\n\n\u003e Responsive Images for Statamic 3.\n\n\u003c!-- /statamic:hide --\u003e\n\nThis Addon provides responsive images inspired by [Our Medialibrary Package](https://github.com/spatie/laravel-medialibrary).\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/statamic-responsive-images.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/statamic-responsive-images)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Installation\n\nRequire it using Composer.\n\n```\ncomposer require spatie/statamic-responsive-images\n```\n\n## Fieldtype\n\nThis addon includes a fieldtype that allows for full Art direction with responsive images.\n\n![fieldtype](./docs/fieldtype.png)\n\nThis fieldtype is configured with the following yaml configuration:\n\n```yaml\n-\n    handle: image\n    field:\n      use_breakpoints: true\n      allow_ratio: true\n      allow_fit: true\n      breakpoints:\n        - sm\n        - md\n        - lg\n      display: Image\n      instructions: 'Choose image using art direction.'\n      type: responsive\n      icon: assets\n      listable: hidden\n      container: assets\n      restrict: false\n      allow_uploads: true\n```\n\nThe configuration above can be used within Antlers using the responsive tag:\n\n```twig\n{{ responsive:image }}\n```\n\nThe breakpoints are configured in the `breakpoints` array of the config file.\n\n## Using Responsive Images\n\nResponsive Images will generate responsive versions of the images whenever a new asset is uploaded. These presets are determined by this package and not by your own Glide presets.\n\nWe generally recommend setting `statamic.assets.image_manipulation.cache` to `false` so only images actually requested by a browser are generated. The first time the conversion is loaded will be slow, but Glide still has an internal cache that it will serve from the next time. This saves a lot on server resources and storage requirements.\n\n## Templating\n\nPass an image to the `responsive` tag.\n\n```twig\n{{ responsive:image_field }}\n```\n\nThis will render an image tag with the default srcsets. The tag uses JS to define the value of the sizes attribute. This way the browser will always download the correct image.\n\n## Image ratio\n\nYou can make sure images are a certain ratio by passing a `ratio` parameter, either as a string `16/10` or as a float `1.6`.\n\n```twig\n{{ responsive:image_field ratio=\"16/9\" }}\n```\n\n## Responsive placeholder\n\nBy default, responsive images generates a small base64 encoded placeholder to show while your image loads. If you want to disable this you can pass `placeholder=\"false\"` to the tag.\n\n```twig\n{{ responsive:image_field placeholder=\"false\" }}\n```\n\n## Additional image format generation\n\nBy default, responsive tag generates original source image file format and WEBP variants of the image, so if you use a JPG image as source then by default JPG and WEBP variants will be generated. You can toggle WEBP and AVIF variant generation with the tag parameters.\n\n```twig\n{{ responsive:image_field webp=\"true\" avif=\"false\" }}\n```\n\nYou can also toggle this in responsive-images.php config file, it will apply your preferences globally.\n\n```php\n'webp' =\u003e true,\n'avif' =\u003e false,\n```\n\n## Image quality\n\nImage format quality settings can be set globally through config. If you wish to override the config quality values you can use tag parameters. You can utilize breakpoints for the quality parameter too!\n\n```twig\n{{ responsive:image_field quality:webp=\"50\" md:quality:webp=\"75\" }}\n```\n\n## Glide parameters\n\nYou can still pass any parameters from the Glide tag that you would want to, just make sure to prefix them with `glide:`.\nPassing `glide:width` will consider the width as a max width, which can prevent unnecessary large images from being generated.\n\n```twig\n{{ responsive:image_field glide:blur=\"20\" glide:width=\"1600\" }}\n```\n\n## HTML Attributes\n\nIf you want to add additional attributes (for example a title attribute) to your image, you can add them as parameters to the tag, any attributes will be added to the image.\n\n```twig\n{{ responsive:image_field alt=\"{title}\" class=\"my-class\" }}\n```\n\n## Breakpoints \u0026 Art direction\n\nYou can define breakpoints in the config file, by default the breakpoints of TailwindCSS are used.\n\nBreakpoints allow you to use, for example, different ratios:\n\n```twig\n{{ responsive:image_field ratio=\"1/1\" lg:ratio=\"16/9\" 2xl:ratio=\"2/1\" }}\n```\n\nThis will apply a default ratio of `1/1`. From breakpoint `lg` up to `2xl`, the ratio will be `16/9`. From `2xl` up, the ratio will be `2/1`.\nThe breakpoints can be configured in the config and default to the breakpoints of Tailwind CSS.\n\nOr different assets:\n\n```twig\n{{ responsive:image_field :lg:src=\"image_field_lg\" :2xl:src=\"image_field_2xl\" }}\n```\n\nBreakpoints support the `ratio`, `src`, `quality` and `glide` parameters.\n\n## Customizing the generated html\n\nIf you want to customize the generated html, you can publish the views using\n\n```bash\nphp artisan vendor:publish\n```\n\nand choosing `Spatie\\ResponsiveImages\\ServiceProvider`\n\n## Generate command\n\nIf you need to regenerate the responsive images for a reason, you can use the `regenerate` command which will clear the Glide cache and regenerate the versions. This command only works when you have the `statamic.assets.image_manipulation.cache` config option set to `true` (which we generally don't recommend).\n\n```bash\nphp please responsive:regenerate\n```\n\nIf you are using a service, like Horizon, for queues then jobs will be queued to handle the image resizing.\nBy default, the job is queued under the 'default' queue. This can be changed via the `queue` config key under `responsive-images.php`\n\nIt is also possible to exclude certain containers from generation responsive variants. You can exclude these containers by adding the handle of the container to the `excluded_containers` array in `responsive-images.php`.\n\n## GraphQL\n\nThis addon comes with 2 GraphQL goodies, it adds a `responsive` field to assets and responsive fieldtype, allowing you to use this addon like you would with the Antlers tag. Secondly you can just let responsive fieldtype augment itself without passing any arguments.\n\n### Responsive field on assets / assets fieldtype / responsive fieldtype\n\nYou can retrieve a responsive version of an `image` asset fieldtype like this:\n\n```graphql\n{\n  entries {\n    data {\n      id,\n      image {\n        responsive(ratio: 1.2) {\n          label\n          minWidth\n          widthUnit\n          ratio\n          sources {\n            format\n            mimeType\n            minWidth\n            mediaWidthUnit\n            mediaString\n            srcSet\n            placeholder\n          }\n        }\n      }\n    }\n  }\n}\n```\n\nMajority of tag parameters are available as arguments in the responsive field, the parameters just need to have colons replaced with underscores. For example, `lg:glide:filter` would become `lg_glide_filter`.\n\nIf you are unsure what arguments are available, try out the GraphQL explorer in the control panel located at `/cp/graphiql` and utilize the autocomplete feature.\n\n### Images from the responsive fieldtype\n\nA responsive fieldtype has all the same fields as a normal responsive field from an asset, except they're under a `breakpoints` key and you cannot pass any arguments to it.\n\n```graphql\n{\n  entries {\n    data {\n      id,\n      art_image {\n        breakpoints {\n          label\n          minWidth\n          widthUnit\n          ratio \n          sources {\n            format\n            mimeType\n            minWidth\n            mediaWidthUnit\n            mediaString\n            srcSet\n            placeholder\n          }\n        }\n      }\n    }\n  }\n}\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Credits\n\n- [Rias Van der Veken](https://github.com/riasvdv)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fstatamic-responsive-images","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Fstatamic-responsive-images","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fstatamic-responsive-images/lists"}