Download the PHP package vendbits/imgixer without Composer
On this page you can find all versions of the php package vendbits/imgixer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package imgixer
Imgixer plugin for Craft CMS 3.x
The most flexible Imgix URL generator for Craft CMS.
- Generate Imgix URLs with convenient methods for responsive images.
- New: Speed up your templates and control panel by swapping Craft's native image transforms with Imgix rendering.
- New: Servd.host users - use Servd's built-in image transforms instead of Imgix.
Requirements
This plugin requires Craft CMS 3.0.0-beta.23 or later.
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require croxton/imgixer
- In the Control Panel, go to Settings → Plugins and click the “Install” button for Imgixer.
Configuring Imgixer
Copy config.php
into Crafts config
folder and rename it to imgixer.php
.
Define each source with a unique handle. The same Imgix source domain may be referenced more than once, which can be useful if you want to use a different set of default parameters for images in a particular Asset volume, or an arbitrary grouping of images with similar characteristics, or if you have defined your Imgix source as a web proxy and need to reference multiple domains.
Using Imgixer
Using Imgixer with Servd.host asset sources
There are several ways to use Imgixer with Servd.host asset sources, and benefit from Servd's automatic environment prefixing (generated URLs are prefixed with local
, staging
or production
).
With either option, you will first need to install Servd Assets and Helpers.
1. Using an Imgix Web Folder source
-
Set up a Web Folder source in Imgix with the base URL set to Servd's CDN URL for your project, e.g.
https://cdn2.assets-servd.host/my-served-project-slug
. -
Recommended: tick the option to use secure URLs and make a note of the key.
- Create a source in
imgixer.php
config, addingservd
as the asset transform provider:
2. Use Servd's own image transformation service
Servd provides its own image transformation service that supports a subset of Imgix's Rendering API, that nonetheless covers most use cases. This does NOT require an Imgix account, but note that it does consume the Servd resources allocated to your plan.
Create a source in imgixer.php
config, adding servd
as the asset provider. Do not set a domain:
Servd's image transformation service supports the following parameters:
fm - output format
Can be one of: webp, png, jpeg, tiff.
w - width
Scales image to supplied width while maintaining aspect ratio.
h - height
Scales image to supplied height while maintaining aspect ratio.
q - quality
(75) - 1-100
ar - aspect-ratio
(1.0:1.0) - When fit=crop, an aspect ratio such as 16:9 can be supplied, optionally with a height or width. If neither height or width are defined, the original image size will be used.
dpr - device-pixel-ratio
(1) - scales requested image dimensions by this multiplier.
fit - resize fitting mode
Can be one of: fill, scale, crop, clip, min, max.
fill-color
Used when fit is set to fill can be a loosely formatted color such as "red" or "rgb(255,0,0)".
crop - resize fitting mode
Can be one of: focalpoint, entropy, any comma separated combination of top, bottom, left right.
crop=focalpoint
Uses the fp-x and fp-y parameters to crop as close to the supplied point as possible.
crop=entropy
Crops the image around the region with the highest Shannon entropy.
crop=top,left (or bottom, right)
Crops the image around the region specified. Supply up to two region identifiers comma separated.
fp-x, fp-y - focal point x & y
Percentage, 0 to 1 for where to focus on the image when cropping with focalpoint mode.
auto
Can be a comma separated combination of: compress, format.
auto=format
If auto includes format, the service will try to determine the ideal format to convert the image to. The rules are:
- If the browser supports it, everything except for gifs is returned as webp.
- If a png is requested and that png has no alpha channel, it will be returned as a jpeg.
auto=compress
The compress parameter will try to run post-processed optimizations on the image prior to returning it.
Png images will run through pngquant.
Element API
Pass the image as the first argument to the function, and an array of Imgix parameters as the second argument.
Web proxy
When using Imgix as a proxy you need to provide the absolute URL to the image you want to proxy. You can do that at the template level (if you need to proxy multiple domains), or create a source
for each proxied domain in your config and pass the proxy domain to the subfolder
.
So for example you can have a config like this...
...and use like this in templates:
Alternatively, use a config like this...
...and use like this in templates: