gwhthompson/laravel-cloudflare-transforms

Fluent API for Cloudflare Image Transformation URLs in Laravel

Maintainers

Package info

github.com/gwhthompson/laravel-cloudflare-transforms

pkg:composer/gwhthompson/laravel-cloudflare-transforms

Statistics

Installs: 133

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

v3.2.2 2025-12-19 14:01 UTC

This package is auto-updated.

Last update: 2026-03-01 00:48:41 UTC


README

Tests codecov Latest Version License Total Downloads PHP Version

Fluent API for Cloudflare Image Transformations.

Installation

Requires PHP 8.3+ and Laravel 11+.

composer require gwhthompson/laravel-cloudflare-transforms

Set your disk's url to a Cloudflare-proxied domain:

// config/filesystems.php
'media' => [
    'driver' => 's3',
    'url' => env('CLOUDFLARE_CDN_URL'), // https://cdn.example.com
    // ...
],

Usage

Storage::disk('media')->image('photo.jpg')
    ->width(400)
    ->format(Format::Auto)
    ->url();
// → https://cdn.example.com/cdn-cgi/image/w=400,f=auto/photo.jpg

// Responsive srcset
Storage::disk('media')->image('hero.jpg')
    ->srcset([320, 640, 960, 1280]);

// Convenience methods
->optimize()     // format=auto, quality=high
->thumbnail(150) // square crop
->grayscale()

Blade Component

<x-cloudflare:image
    path="hero.jpg"
    :width="1200"
    :fit="Fit::Cover"
    :srcset="[320, 640, 960, 1280]"
    sizes="(max-width: 640px) 100vw, 50vw"
/>

Enums

Enum Values
Fit Contain, Cover, Crop, Pad, ScaleDown, Squeeze
Format Auto, Avif, Jpeg, Webp
Quality High, MediumHigh, MediumLow, Low
Gravity Auto, Top, Bottom, Left, Right, Face

Configuration

php artisan vendor:publish --tag=cloudflare-transforms-config
Option Default Purpose
domain null Fallback for CloudflareImage::make()
transform_path cdn-cgi/image Custom path with URL rewrite
validate_file_exists true Disable for performance

Testing

# .env.testing
CLOUDFLARE_VALIDATE_FILE_EXISTS=false

Security

Report vulnerabilities to security@unfetter.co.

License

MIT