We 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. We publish all received postcards on our virtual postcard wall.

Installation

Require it using Composer.

composer require spatie/statamic-responsive-images

Using Responsive Images

Responsive Images will generate responsive versions of the images whenever a new asset is uploaded. If 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:

php please responsive:regenerate

Templating

Pass an image to the responsive tag.

{{ responsive:image_field }}

Image ratio

You 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.

{{ responsive:image_field ratio="16/9" }}

Responsive placeholder

By 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.

{{ responsive:image_field placeholder="false" }}

Webp image generation

By default, responsive images generates webp variants in addition to jpg or png versions of your image, these are usually smaller. If you want to disable this functionality you can pass webp="false" to your tag.

{{ responsive:image_field webp="false" }}

Glide parameters

You can still pass any parameters from the Glide tag that you would want to, just make sure to prefix them with glide:.
Passing glide:width will consider the width as a max width, which can prevent unnecessary large images from being generated.

{{ responsive:image_field glide:blur="20" glide:width="1600" }}

HTML Attributes

If 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.

{{ responsive:image_field alt="{title}" class="my-class" }}

Customizing the generated html

If you want to customize the generated html, you can publish the views using