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

On this page you can find all versions of the php package spatie/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

Latest Version Statamic 4.0+

Responsive Images

Responsive Images for Statamic 3.

This Addon provides responsive images inspired by Our Medialibrary Package.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

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.

Fieldtype

This addon includes a fieldtype that allows for full Art direction with responsive images.

This fieldtype is configured with the following yaml configuration:

The configuration above can be used within Antlers using the responsive tag:

The breakpoints are configured in the breakpoints array of the config file.

Using Responsive Images

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

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

Templating

Pass an image to the responsive tag.

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

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

Additional image format generation

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

You can also toggle this in responsive-images.php config file, it will apply your preferences globally.

Image quality

Image 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!

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.

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.

Breakpoints & Art direction

You can define breakpoints in the config file, by default the breakpoints of TailwindCSS are used.

Breakpoints allow you to use, for example, different ratios:

This 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. The breakpoints can be configured in the config and default to the breakpoints of Tailwind CSS.

Or different assets:

Breakpoints support the ratio, src, quality and glide parameters.

Customizing the generated html

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

and choosing Spatie\ResponsiveImages\ServiceProvider

Generate command

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. This command only works when you have the statamic.assets.image_manipulation.cache config option set to true (which we generally don't recommend).

If you are using a service, like Horizon, for queues then jobs will be queued to handle the image resizing. By default, the job is queued under the 'default' queue. This can be changed via the queue config key under responsive-images.php

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

GraphQL

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

Responsive field on assets / assets fieldtype / responsive fieldtype

You can retrieve a responsive version of an image asset fieldtype like this:

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

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

Images from the responsive fieldtype

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

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of statamic-responsive-images with dependencies

PHP Build Version
Package Version
Requires statamic/cms Version ^5.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 spatie/statamic-responsive-images contains the following files

Loading the files please wait ....