Download the PHP package teamzac/cloudinary-url-builder without Composer
On this page you can find all versions of the php package teamzac/cloudinary-url-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download teamzac/cloudinary-url-builder
More information about teamzac/cloudinary-url-builder
Files in teamzac/cloudinary-url-builder
Package cloudinary-url-builder
Short Description A fluent Cloudinary URL builder
License MIT
Homepage https://github.com/team-zac/cloudinary
Informations about the package cloudinary-url-builder
Fluent Cloudinary image transformations
Cloudinary is awesome but I wanted a more expressive way to apply transformations to an image than their official package provides. This is not a replacement for the official API client, it just provides a different way to generate image URLs based on the transformations you wish to apply. It also provides a way to create pre-defined groups of transformations as presets.
Installation
You can install the package via composer:
Usage
This package uses the official Cloudinary PHP library under the hood, which has a variety of global config options. If you are using Laravel, the auto-registered service provider for this package will set the default cloud name for you based on the value in this package's config.
You can set this value by adding a key for CLOUDINARY_CLOUD_NAME
to your .env file. If you'd like to take ownership of the package's config file, you can run the following command:
and choose the TeamZac\Cloudinary\ServiceProvider
option.
The core functionality is provided with the TeamZac\Cloudinary\Builder
class. You can access it directly, or utilize the facade, to apply transformations and generate an image URL.
To build a pre-defined set of transformations, you can subclass the Builder class and override the initializePreset
method. There, you can apply all the transformations you want. This method gets called before building the URL, and only once in case you plan to reuse the same instance of your preset class.
You can instantiate your own preset classes directly, or you can extend the Builder in a service provider to name your presets. You can then create a new instance using the preset
method:
This could be useful for something like a hero image on a blog, where you want a similar transformation to be applied to each image but might have a light and dark variant. You could store the transformation preset on the post model and dynamically refer to it in your template.
Most of the effects Cloudinary provides are either parameterless or just allow a single value. In many cases, we've included the same defaults that Cloudinary uses so you can exclude passing any parameters if you're fine with the defaults. We still need to add Cloudinary's defaults to some of the effect methods.
In some cases, the effects can be a bit more complex. For example, you can create an Outline effect using the outline
method, with an optional callback to customize additional options:
Testing
Todo
- several effects whose options are more involved have yet to be added to this package
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Chad Janicek
- Laravel Package Boilerplate
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of cloudinary-url-builder with dependencies
cloudinary/cloudinary_php Version ^1.18
illuminate/support Version ^7.0|^8.0