imgix-craft
A plugin providing the power of Imgix to your CraftCMS project!
Installation
- Set up a fully functional CraftCMS project on your host.
- Clone the imgix-craft project and run
cp ${clonedPlugin}/imgix-craft/imgixforcraft/ ${craftInstall}/craft/plugins
- Download composer:
curl -sS https://getcomposer.org/installer | php
cd
into${craftInstall}/craft/plugins
and install dependencies:php composer.phar install
- Start httpd, and visit
localhost/admin
, or whatever URL your craft project is rooted. - Navigate to the plug in menu and install imgix-craft
- Create a new Imgix source that points to the public URL of your craft install.
- In the settings menu, enter the name of you imgix source root URL, and optionally a secure URL token if needed. Save.
Usage
imgix-craft provides a template variable that intercepts the URL of an image asset and points it instead to its counterpart on an Imgix source. This is to be used as the value of the src
attribute of an <img>
tag. It takes in an image asset as a parameter. For example:
{% set locationEntry = craft.entries.section('locations').first %}
{% set image = locationEntry.featuredImage.first() %}
<img src="{{ craft.imgixForCraft.imgixify(image) }}"/>
You can also specify any transformations available on Imgix's URL API as an optional second parameter. The second parameter accepts an associative array of parameters from the API:
{% set locationEntry = craft.entries.section('locations').first %}
{% set image = locationEntry.featuredImage.first() %}
<img src="{{ craft.imgixForCraft.imgixify(image,{h:500, w: 500, rot: 30 }) }}"/>
Happy Imgixification!