Download the PHP package ghijk/cloudflare-super-images without Composer
On this page you can find all versions of the php package ghijk/cloudflare-super-images. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ghijk/cloudflare-super-images
More information about ghijk/cloudflare-super-images
Files in ghijk/cloudflare-super-images
Package cloudflare-super-images
Short Description A Laravel package for Cloudflare Images: build delivery URLs, mint direct creator uploads, and manage assets.
License MIT
Homepage https://github.com/1stevengrant/cloudflare-super-images
Informations about the package cloudflare-super-images
Cloudflare Super Images
A Laravel package for Cloudflare Images. Build flexible delivery URLs, mint Direct Creator Upload URLs, verify uploads, and clean up assets, all from a clean, fluent API.
What it does
- Flexible delivery URLs. Build
imagedelivery.netURLs with width, height, fit, quality, and format through a fluent builder. - Background removal. Append
segment=foreground(Cloudflare's BiRefNet model) with a single chainable call. Transparency-safe format handling is automatic. - Smart crops. Use
gravity=facewith an optionalzoomto keep portraits framed. - Presets and named variants. Ship with thumbnail, classic, and hero presets, or point at dashboard variants.
- Direct Creator Upload. Mint one-time upload URLs so the browser uploads straight to Cloudflare, bypassing your application's request body limits.
- Upload verification. Poll with exponential backoff until a draft upload flips to ready.
This package relies on Flexible Variants being enabled on your account (Dashboard, Images, Hosted Images, Delivery) so arbitrary transformation parameters such as w=600,fit=cover render.
Installation
Publish the config file:
Configuration
Add your Cloudflare credentials to .env:
| Variable | Purpose |
|---|---|
CF_ACCOUNT_ID |
Your Cloudflare account ID. |
CF_ACCOUNT_HASH |
Public-safe Images delivery hash (Images, Hosted Images, Developer Resources). Safe to expose in markup. |
CF_IMAGES_TOKEN |
API token with Account, Cloudflare Images, Edit, used to mint upload URLs and manage assets. |
Building delivery URLs
The builder casts to a string, so you can use it directly in markup or pass it anywhere a string is expected.
Blade component
Any extra attributes (alt, class, loading) pass straight through to the rendered <img> tag.
Inertia (React and Vue)
The package ships React and Vue components that build delivery URLs on the client from an imageId, so one image can render at many sizes without a server prop per variant. They share a small TypeScript port of the URL builder.
Publish the stubs into your app, where your existing Vite and TypeScript pipeline compiles them:
This copies buildImageUrl.ts, react/CloudflareImage.tsx, and vue/CloudflareImage.vue into resources/js/vendor/cloudflare-super-images.
Share your public delivery hash once so the components can read it. In app/Http/Middleware/HandleInertiaRequests.php:
Then use the component. Options map onto the same names as the PHP builder, and extra attributes pass through to the <img>:
If you would rather not share the hash globally, pass it explicitly with an accountHash prop. To keep the URL built on the server instead, drop the components and pass CloudflareImages::url($id)->...->toString() as a plain string prop.
Direct Creator Upload
Mint a one-time upload URL and hand it to the browser:
The browser then POSTs the file directly to $upload->uploadUrl. Once that completes, verify the asset before persisting anything that points at it:
Reading and deleting assets
How upload works
Testing
The package ships with Http::fake() driven tests for the API client and pure unit tests for the URL builder.
Credits
Ported from a TanStack Start on Cloudflare Workers demo into a reusable Laravel package.
License
The MIT License (MIT). Please see License File for more information.
All versions of cloudflare-super-images with dependencies
illuminate/contracts Version ^10.0||^11.0||^12.0
spatie/laravel-package-tools Version ^1.16