Download the PHP package acalvino4/craft-easy-image without Composer

On this page you can find all versions of the php package acalvino4/craft-easy-image. 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 craft-easy-image

Easy Image

Maximally optimized images with minimal code.

License Build Status

Test Coverage Phpstan Level Easy Coding Standard

Intro

The markup necessary for maximally optimized images is complex. You have to know a lot to get it right, and even when you do, propogating and enforcing this knowledge across a team, not to mention implementing it without stray mistakes, is a challenge. Just some of the things you need to know are

But what if you didn't have to think about all that, and instead got correct markup just by specifying your asset, a transform set name, and whatever html attributes you want applied?

Most image optimization plugins require too much configuration or don't use the latest best practices. If your transform service supports avif, you shouldn't need to specify that for every transform. Usually you want 'cover' mode. The main thing that changes between transform sets is the resize dimensions, so that's all we'll make you configure (everything else is optional but still possible).

This plugin brings optimized (but configurable) transform defaults, and a twig function to output all the correct picture markup without you having to think about it.

We provide no-stress generation of markup that

all with

Usage

In config/easy-image.php include something like the following (see annotated config.php in plugin's src directory):

Then, wherever you need a hero image, just use this in your twig markup:

which will output something like

A few things to note

API

Config

Config is set through config/easy-image.php. Follow example above, or check out vendor/acalvino4/easy-image/src/config.php for a more thoroughly annotated example.

Picture Twig Function

We'll show the function signature, give some explanation, then some examples.

Signature

Explanation

Examples

The basic use case was demonstrated above:

Notice that when the $attributes argument is a string, it is interpreted as a class list.

The most complex case would look something like this:

This example will load an alternate image on small screens, using the 'hero-mobile' transform set. On screens 768px and larger, it will use the same image and 'hero' transform set from before.

In both cases, the generated markup will contain the data-something attribute, and will not lazy load.

Sizes

If you use this plugin to generate your image markup as described above, you'll be doing great! But to really optimize, you should pass in the sizes attribute to the attribute list. By default, the browser will pick from your srcset based on which width descriptor matches your browser viewport width. This is necessary because while css styling may constrain the width of an image to, say, 50% of the page for a two column layout, or a flat 50px, the browser may need to request these images before the css is loaded. If your image is full-width, then you're all good, but many times an image only takes up a small fraction of the viewport - for example, a thumbnail image.

The sizes attribute describes how wide your image will display directly in the html so the browser can request the appropriate image directly. It should often mirror your css styling, as in below examples, but keep in mind that parent containers may also constrain an image's width. Keep in mind that the browser will use the first media query matched, so list the more general cases last.

Sizes Examples

Placeholder Images

This plugin will inline a blurry version of your image until your image loads; there is nothing you need to do. It generates this image via the Blur Hash plugin, which is automatically included. By default, that plugin will generate placeholders with a max size of 64px in the larger direction, which comes out to a few kb in size. Because this is rather larger to inline, I recommend overriding this by including the following in config/blur-hash.php:

This will generally reduce the size to less than 500 bytes (around 250 in my tests), while retaining a decent amount of detail and avoiding pixelation. You can play around with this to find the right balance for you between data uri size and detail.

The other thing to note is that this dependency is licensed as "treeware", meaning you are asked to donate to plant trees when you use it in production. This can be a one-time donation, and there is no minumim.

Usage with and comparison to other image optimization / transform plugins

See accompanying doc.

Requirements

This plugin requires Craft CMS 4.4.0 or later, and PHP 8.0.2 or later.

Warning If doing local transforms, ImageMagick 7 is required to avoid certain bugs (for example, converting a png with transparent background to avif results in a solid black background instead).

Both ddev and the default ubuntu apt package will install ImageMagick 6 by default. I am not aware of a way to upgrade the version in ddev, but for ubuntu, just run the following script as root on your server.

Installation

You can install this plugin from the Plugin Store or with Composer.

From the Plugin Store

Go to the Plugin Store in your project’s Control Panel and search for “Easy Image”. Then press “Install”.

With Composer

Open your terminal and run the following commands:

Roadmap


All versions of craft-easy-image with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
craftcms/cms Version ^5.0.0
dodecastudio/craft-blurhash Version ^3.0.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 acalvino4/craft-easy-image contains the following files

Loading the files please wait ....