PHPackages                             spacecatninja/imager-x-cloudflare-images-transformer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. spacecatninja/imager-x-cloudflare-images-transformer

ActiveCraft-plugin[Image &amp; Media](/categories/media)

spacecatninja/imager-x-cloudflare-images-transformer
====================================================

Cloudflare Images transformer for Imager X

1.0.1(2mo ago)2531↑33.3%2MITPHPPHP ^8.2

Since Jul 18Pushed 2mo agoCompare

[ Source](https://github.com/spacecatninja/craft-imager-x-cloudflare-images-transformer)[ Packagist](https://packagist.org/packages/spacecatninja/imager-x-cloudflare-images-transformer)[ RSS](/packages/spacecatninja-imager-x-cloudflare-images-transformer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Cloudflare Images transformer for Imager X
==========================================

[](#cloudflare-images-transformer-for-imager-x)

A plugin for using [Cloudflare Images](https://developers.cloudflare.com/images/) [transformations](https://developers.cloudflare.com/images/transform-images/)as a transformer in Imager X. Also, an example of [how to make a custom transformer for Imager X](https://imager-x.spacecat.ninja/extending.html#transformers).

*Please note, this plugin does not enable you to store images on Cloudflare, it only enable you to optimize any publicly available image on the Internet.*

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 5.0.0 or later, [Imager X 5.0.0](https://github.com/spacecatninja/craft-imager-x/) or later, and an account with [Cloudflare](https://cloudflare.com/).

Setting up Cloudflare Images
----------------------------

[](#setting-up-cloudflare-images)

To enable transformations in Cloudflare, go to Images &gt; Transformations from you account home, and click "Enabled" on the zone you wish to use. This domain goes into the required `zoneDomain` config setting, see below.

By default, this enables you to transform any image stored inside this domain. If you want to transform images on other domains, like a staging domain, a tunnel-domain to you local server, some third-party service (thumbs from YouTube, Vimeo, etc), or something else, you need to add these domains to the list of "Sources" in the details for the domain (click the domain in the list in "Transformations").

You can also allow transformations from "Any origin", but this is not recommended as you'd be running an Image transform service that anyone on the internet could use to transform their own images with.

Usage
-----

[](#usage)

Install and configure this transformer as described below. Then, in your [Imager X config](https://imager-x.spacecat.ninja/configuration.html), set the transformer to `cloudflareimages`, ie:

```
'transformer' => 'cloudflareimages',

```

Transforms are now by default transformed with Cloudflare Images, test your configuration with a simple transform like this:

```
{% set transform = craft.imagerx.transformImage(asset, { width: 600 }) %}

URL is: {{ transform.url }}

```

If this doesn't work, make sure the assets you're trying to transform are publicly available, and that the zone includes the location of the files (see above).

### Cave-ats, shortcomings, and tips

[](#cave-ats-shortcomings-and-tips)

This transformer only supports a subset of what Imager X can do when using the default `craft` transformer. The Cloudflare Images API is quite limited, but supports the most common use-cases. Please refer to the [Cloudflare Images documentation](https://developers.cloudflare.com/images/transform-images/transform-via-url/) for a complete list of what's supported.

Crop modes, width, height, ratio, quality and format, are automatically converted from the standard Imager parameters, while the rest of the additional options can be passed directly to Cloudflare using the `transformerParams` transform parameter. Example:

```
{% set transforms = craft.imagerx.transformImage(asset,
    [400, 1200, 2/1],
    { transformerParams: { brightness: 1.2, sharpen: 1 } }
) %}

```

As with all external services for image transforms, figuring out a way to work with it in development can be tricky. I generally recommend having the images in a staging environment (or production when the site is live) where you add any test content that you need, sync databases, and point the asset URLs, and the cloudflare sources, to that when working locally. You can also use grok or similar to tunnel through to your local dev server, but it quickly gets a bit tiresome to keep updated. And you can of course use the default `craft` transformer when working locally, and `cloudflareimages` in production.

Note that you can easily combine local transforms with Cloudflare transforms. Since Cloudflare doesn't really care where on the zone domain something is stored, you can do one transform with the local `craft` transformer, and pass the result to Cloudflare to transform further. This can be useful if you want to use some functionality that is not supported by Cloudflare, but is in Imager. Example:

```
{% mySpecialTransform = craft.imagerx.transformImage({ effects: { modulate: [90,50,100] } }, {}, { transformer: 'craft' }) %}
{% transforms = craft.imagerx.transformImage(mySpecialTransform, [600, 1800, 16/9]) %}

```

This of course requires that Cloudflare can access the image generated in the first step, so in this case, if you try it on a local dev server, you need to figure out how to enable that.

Installation
------------

[](#installation)

To install the plugin, follow these instructions:

1. Install with composer via `composer require spacecatninja/imager-x-cloudflare-images-transformer` from your project directory.
2. Install the plugin in the Craft Control Panel under Settings &gt; Plugins, or from the command line via `craft plugin/install imager-x-cloudflare-images-transformer`.

Configuration
-------------

[](#configuration)

You can configure the transformer by creating a file in your config folder called `imager-x-cloudflare-images-transformer.php`, and override settings as needed.

### zoneDomain \[string\]

[](#zonedomain-string)

Default: `''`
This is your cloudflare zone that has transformations enabled, and it's required for the plugin to work.

#### defaultParams \[array\]

[](#defaultparams-array)

Default: `[]`
Default params to be passed to every transform. This is very handy for a couple of things, like:

```
'defaultParams' => [
    'format' => 'auto',
    'quality' => 80
 ]

```

*`'format' => 'auto'` should be the default in most cases. Cloudflare will then determine what modern image formats the browser supports (ie, webp or avif), and deliver the best one.*

It's also tempting to set `'gravity' => 'auto'` here, but see below.

### autoGravityWhenNoFocalPoint \[bool\]

[](#autogravitywhennofocalpoint-bool)

Default: `false`
This setting automatically applies `'gravity' => 'auto'` to transformations when an asset lacks a defined focal point. Unlike adding this parameter directly to `defaultParams` or in your transform configuration, enabling this setting preserves Craft's built-in focal point functionality. This gives you dual benefits:

1. Automatic focal point detection for assets without manually defined focal points
2. The ability to override automatic detection by setting focal points in Craft when needed

This approach provides flexibility while maintaining control over image transformations, especially useful when automatic detection doesn't produce optimal results.

Price, license and support
--------------------------

[](#price-license-and-support)

The plugin is released under the MIT license. It requires Imager X, which is a commercial plugin [available in the Craft plugin store](https://plugins.craftcms.com/imager-x). If you need help, or found a bug, please post an issue in this repo, or in Imager X' repo (preferably).

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance86

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~232 days

Total

2

Last Release

66d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/806fbb515be53ddbca1d658f1abe7f8ddd41d77b72eec8aa85800db3a03e7e35?d=identicon)[spacecatninja](/maintainers/spacecatninja)

---

Top Contributors

[![aelvan](https://avatars.githubusercontent.com/u/2675644?v=4)](https://github.com/aelvan "aelvan (5 commits)")[![low](https://avatars.githubusercontent.com/u/59516?v=4)](https://github.com/low "low (1 commits)")

---

Tags

imageimagescmstransformcloudflareresponsiveCraftcraftcmscraft-pluginpicturesrcset

### Embed Badge

![Health badge](/badges/spacecatninja-imager-x-cloudflare-images-transformer/health.svg)

```
[![Health](https://phpackages.com/badges/spacecatninja-imager-x-cloudflare-images-transformer/health.svg)](https://phpackages.com/packages/spacecatninja-imager-x-cloudflare-images-transformer)
```

###  Alternatives

[spacecatninja/imager-x

Ninja powered image transforms.

29390.0k23](/packages/spacecatninja-imager-x)[nystudio107/craft-imageoptimize

Automatically create &amp; optimize responsive image transforms, using either native Craft transforms or a service like imgix, with zero template changes.

232337.2k16](/packages/nystudio107-craft-imageoptimize)[nystudio107/craft-youtubeliveembed

This plugin allows you to embed a YouTube live stream and/or live chat on your webpage

163.7k](/packages/nystudio107-craft-youtubeliveembed)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
