The tests have a few external dependencies. To install those:
Just copy the files to your project, and include the
src/autoload.php file. We recommend using Composer if at all possible.
Define the following requirement in your
And include the global
To begin creating imgix URLs programmatically, add the php files to your project (an example autoloader is also provided). The URL builder can be reused to create URLs for any images on the domains it is provided.
HTTPS support is available by default. However, if you need HTTP support, call
setUseHttps on the builder:
To produce a signed URL, you must enable secure URLs on your source and then provide your signature key to the URL builder.
The imgix library allows for generation of custom
srcset attributes, which can be invoked through
createSrcSet(). By default, the
srcset generated will allow for responsive size switching by building a list of image-width mappings.
Will produce the following attribute value, which can then be served to the client:
In cases where enough information is provided about an image's dimensions,
createSrcSet() will instead build a
srcset that will allow for an image to be served at different resolutions. The parameters taken into consideration when determining if an image is fixed-width are
ar. By invoking
createSrcSet() with either a width or the height and aspect ratio (along with
fit=crop, typically) provided, a different
srcset will be generated for a fixed-size image instead.
Will produce the following attribute value:
For more information to better understand
srcset, we highly recommend Eric Portis' "Srcset and sizes" article which goes into depth about the subject.
More Core Libraries
- imgix-csharpbuildA C# client library for generating image URLs with imgixC# 12 2 days ago
- imgix-elixirbuildAn Elixir client library for generating image URLs with imgixElixir 30 4 months ago
- imgix-gobuildA Go client library for generating image URLs with imgixGo 2 6 months ago
- imgix-javabuildA Java client library for generating URLs with imgixJava 14 < 1 day ago
- imgix-pythonbuildA Python client library for generating URLs with imgixPython 25 < 1 day ago
- imgix-rbbuildA Ruby gem for generating image URLs with imgixRuby 65 10 days ago
- imgix-swiftbuildA Swift client library for generating URLs with imgixSwift 19 3 months ago