bakerkretzmar/laravel-cloudinary

This package is abandoned and no longer maintained. No replacement package was suggested.

Cloudinary API wrapper for Laravel

dev-master 2019-08-20 13:24 UTC

This package is auto-updated.

Last update: 2023-10-20 22:59:26 UTC


README

Build Status StyleCI

Latest stable version Total downloads MIT license

Cloudinary API wrapper for Laravel.

Installation

composer require bakerkretzmar/laravel-mapbox

Configuration

Add the following to your .env file:

# Required
CLOUDINARY_CLOUD_NAME={your Cloudinary cloud name}
CLOUDINARY_API_KEY={your Cloudinary API key}
CLOUDINARY_API_SECRET={your Cloudinary API secret}

# Optional
CLOUDINARY_BASE_URL={custom base asset URL}
CLOUDINARY_SECURE_URL={secure custom base asset URL}

Optionally, you can publish the package’s config file:

php artisan vendor:publish --provider="Bakerkretzmar\LaravelCloudinary\LaravelCloudinaryServiceProvider"

Usage

upload()

Cloudder::upload($filename, $publicId, array $options, array $tags);

with:

  • $filename: path to the image you want to upload
  • $publicId: the id you want your picture to have on Cloudinary, leave it null to have Cloudinary generate a random id.
  • $options: options for your uploaded image, check the Cloudinary documentation to know more
  • $tags: tags for your image

returns the CloudinaryWrapper.

uploadVideo()

Cloudder::uploadVideo($filename, $publicId, array $options, array $tags);

with:

  • $filename: path to the video you want to upload
  • $publicId: the id you want your video to have on Cloudinary, leave it null to have Cloudinary generate a random id.
  • $options: options for your uploaded video, check the Cloudinary documentation to know more
  • $tags: tags for your image

returns the CloudinaryWrapper.

getPublicId()

Cloudder::getPublicId()

returns the public id of the last uploaded resource.

getResult()

Cloudder::getResult()

returns the result of the last uploaded resource.

show() + secureShow()

Cloudder::show($publicId, array $options)
Cloudder::secureShow($publicId, array $options)

with:

  • $publicId: public id of the resource to display
  • $options: options for your uploaded resource, check the Cloudinary documentation to know more

returns the url of the picture on Cloudinary (https url if secureShow is used).

showPrivateUrl()

Cloudder::showPrivateUrl($publicId, $format, array $options)

with:

  • $publicId: public id of the resource to display
  • $format: format of the resource your want to display ('png', 'jpg'...)
  • $options: options for your uploaded resource, check the Cloudinary documentation to know more

returns the private url of the picture on Cloudinary, expiring by default after an hour.

rename()

Cloudder::rename($publicId, $toPublicId, array $options)

with:

  • $publicId: publicId of the resource to rename
  • $toPublicId: new public id of the resource
  • $options: options for your uploaded resource, check the cloudinary documentation to know more

renames the original picture with the $toPublicId id parameter.

destroyImage() + delete()

Cloudder::destroyImage($publicId, array $options)
Cloudder::delete($publicId, array $options)

with:

  • $publicId: publicId of the resource to remove
  • $options: options for the image to delete, check the cloudinary documentation to know more

removes image from Cloudinary.

destroyImages()

Cloudder::destroyImages(array $publicIds, array $options)

with:

  • $publicIds: array of ids, identifying the pictures to remove
  • $options: options for the images to delete, check the cloudinary documentation to know more

removes images from Cloudinary.

addTag()

Cloudder::addTag($tag, $publicIds, array $options)

with:

  • $tag: tag to apply
  • $publicIds: images to apply tag to
  • $options: options for your uploaded resource, check the cloudinary documentation to know more

removeTag()

Cloudder::removeTag($tag, $publicIds, array $options)

with:

  • $tag: tag to remove
  • $publicIds: images to remove tag from
  • $options: options for your uploaded image, check the Cloudinary documentation to know more

createArchive()

Cloudder::createArchive(array $options, $archiveName, $mode)

with:

  • $options: options for your archive, like name, tag/prefix/public ids to select images
  • $archiveName: name you want to give to your archive
  • $mode: 'create' or 'download' ('create' will create an archive and returns a JSON response with the properties of the archive, 'download' will return the zip file for download)

creates a zip file on Cloudinary.

downloadArchiveUrl()

Cloudder::downloadArchiveUrl(array $options, $archiveName)

with:

  • $options: options for your archive, like name, tag/prefix/public ids to select images
  • $archiveName: name you want to give to your archive

returns a download url for the newly created archive on Cloudinary.

Running tests

phpunit

Example

You can find a working example in the repo cloudder-l5-example

Credits

Based on Jeremy Dagorn’s cloudder.