PHPackages                             teamzac/cloudinary-url-builder - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. teamzac/cloudinary-url-builder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

teamzac/cloudinary-url-builder
==============================

A fluent Cloudinary URL builder

v0.1.1(5y ago)09MITPHPPHP ^7.2.5

Since Oct 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/teamzac/cloudinary-url-builder)[ Packagist](https://packagist.org/packages/teamzac/cloudinary-url-builder)[ Docs](https://github.com/team-zac/cloudinary)[ RSS](/packages/teamzac-cloudinary-url-builder/feed)WikiDiscussions master Synced 5d ago

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

Fluent Cloudinary image transformations
=======================================

[](#fluent-cloudinary-image-transformations)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6daed7617d64e177dcc13aa3d24a5e367f08741cb3e53c9b7ac8d2a89850fbc9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7465616d2d7a61632f636c6f7564696e6172792d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/team-zac/cloudinary)

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
------------

[](#installation)

You can install the package via composer:

```
composer require team-zac/cloudinary-url-builder
```

Usage
-----

[](#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:

```
php artisan vendor:publish
```

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.

```
Cloudinary::id('image.jpg')
	->resize(300, 450, 'crop')
	->removeRedEye()
	->sepia(30)
	->getUrl();
```

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.

```
