Download the PHP package craftyhedge/craft-transform-mapper without Composer

On this page you can find all versions of the php package craftyhedge/craft-transform-mapper. 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-transform-mapper

Transform Mapper for Craft CMS

CI PHPStan Level 7 PHP 8.2+ Craft 5 Beta

Beta release – The configuration API is stable enough for production use, but we may still make small non-breaking refinements before 1.0. Report issues on GitHub so we can lock the final shape.

Replace Craft CMS built-in image transforms with config-driven external service URLs. Zero template changes — asset.getUrl(), .srcset(), named transforms, GraphQL @transform, and CP thumbnails all work as before, but transform URLs point to your external image service.

Scope and Requirements

This plugin does not provide filesystem providers or storage services.

Craft Transform Mapper does not register or implement any filesystem adapters (local, S3, GCS, etc.) and does not supply any external image optimization or CDN services (Imgix, Cloudflare Images, etc.).

Users must install and configure their own storage provider plugins and transform services separately. Those plugins handle registering the actual filesystem volumes and transform backends.

This plugin’s only role is to ensure that transforms use the correct URL based transforms service you decide to employ.

Requirements

Installation

The plugin is currently in beta. The configuration API and behavior are stable enough for production use, but we may still make small non-breaking refinements before the 1.0 release.

During the beta period, we recommend using a version constraint such as ^0.1 or 0.1.* so you can control upgrades. Once we reach 1.0, the plain composer require command above will continue to work and will install the stable release.

Quick Start

  1. Install the plugin (see the Installation section above).
  2. Open example-configs and copy the file closest to your image service (Cloudflare, imgix, Bunny, Cloudinary, or the generic webhook example). These are starting points — not all have been tested in production.
  3. Save it as config/transform-mapper.php and set the environment variables it requires.
  4. Point your AI assistant at the @see links in that file’s header (plus the Available Tokens table below) to adapt the urlPattern, parameter mappings, signing, and purge settings.
  5. Ensure 'replaceDefault' => true (the default) so the plugin handles all transforms.

For the full list of configuration options and token behavior, continue to the sections below.

How It Works

The plugin overrides Craft's default ImageTransformer via the Yii DI container. When replaceDefault is true, all calls to Craft::createObject(['class' => ImageTransformer::class]) resolve to TransformMapper — intercepting inline transforms, DB-stored named transforms, and GraphQL @transform directives.

The CP image editor (crop, rotate, flip) continues to work via inherited parent methods.

Limitations

Configuration

The example-configs directory contains ready-to-adapt starting points for the most common providers:

Note on the examples: These are provided as starting points and reference implementations. Not all configurations have been tested in production by the maintainers. If you get one working well for your service, please consider contributing your version — it helps improve the plugin for others.

Each file includes @see links in the header pointing to the official service documentation.

Point your AI agent at the documentation links inside the relevant example (plus the Available Tokens table below) to generate or customize the exact config/transform-mapper.php for your setup.

Copy the closest example to config/transform-mapper.php, set the environment variables it references, and adapt the URL pattern, mappings, signing, and purge logic according to the provider docs linked in the file.

Available Tokens

Token Source Example
{baseUrl} Config baseUrl (trailing slash ensured) https://images.my-service.com/
{path} Raw Asset::getPath() — folder + filename subfolder/image.jpg
{pathRaw} Alias of raw Asset::getPath() subfolder/image.jpg
{pathEncoded} RFC 3986 segment-encoded path (slashes preserved) subfolder/my%20image.jpg
{filename} Filename without extension image
{filenameWithExtension} Filename with extension image.jpg
{folder} Asset::$folderPath subfolder/
{extension} Asset::getExtension() jpg
{width} Transform width 800
{height} Transform height 600
{mode} Transform mode (after mapping) cover
{quality} Transform quality 80
{format} Transform format webp
{position} Transform position center-center
{positionX} Position as normalized X coordinate (0..1) 0.5
{positionY} Position as normalized Y coordinate (0..1) 0.5
{hasFocalPoint} Whether asset has a user-defined focal point 1 or 0
{focalX} Asset focal point X coordinate (0..1), when available 0.42
{focalY} Asset focal point Y coordinate (0..1), when available 0.31
{focusX} Effective focus X (asset focal point, fallback to position) 0.42
{focusY} Effective focus Y (asset focal point, fallback to position) 0.31
{focusCrop} Composite width,height,focusX,focusY value (set for Craft mode crop with both dimensions) 1200,630,0.42,0.31
{interlace} Transform interlace none
{fill} Transform fill color #ffffff
{upscale} Transform upscale flag 1 or 0

Tokens with null values become empty strings. Empty query parameters are automatically stripped. See cleanUrl() in src/helpers/UrlBuilder.php.

Use {path} / {pathRaw} when your provider expects an unencoded source path (for example, Cloudflare Image Resizing and standard imgix source URLs). Use {pathEncoded} when your provider or URL shape requires percent-encoding.

URL Signing

To sign transform URLs, set the optional sign callable in config. The callable receives the unsigned URL and must return a signed URL string. Exceptions thrown by the callable are caught and re-thrown as ImageTransformException. Non-string return values likewise throw ImageTransformException.

See the provider-specific examples (and the official documentation links embedded in their file headers) in example-configs. Use them as templates and point your AI agent at the docs referenced there (plus the Available Tokens table above) to generate the exact config needed for your use case.

Purge Invalidations

When Craft invalidates transforms for an asset, Transform Mapper can notify your external image service so that cached variants are cleared.

Set purgeEnabled to true, then choose one of two transports:

purgeMode controls execution strategy:

If both webhook settings and a custom purge callable are configured, the callable takes precedence. A custom callable returning false is treated as a non-retryable failure.

Async purges require queue workers to be running.

For full details on transports, async retry controls, webhook response policies, status code overrides, logging behavior, payload customization, the webhook JSON format, and production recommendations, see PURGING.md.

A few commonly tuned flags are also available at the top level:


All versions of craft-transform-mapper with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
craftcms/cms Version ^5.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 craftyhedge/craft-transform-mapper contains the following files

Loading the files please wait ...