cloudinary / media-editing
Cloudinary Media Editing PHP SDK
Requires
- php: >=7.3.0
- cloudinary/media-delivery-api: *
- cloudinary/media-editing-api: *
This package is auto-updated.
Last update: 2024-11-29 06:29:29 UTC
README
About
The Cloudinary Media Editing PHP SDK allows you to quickly and easily integrate your application with Cloudinary. Effortlessly edit and deliver your cloud's assets.
Additional documentation
This Readme provides basic installation and usage information. For the complete documentation, see the Media Editing SDK Guide.
Table of Contents
Key Features
Media Delivery API
Media Editing API
Version Support
Installation
composer require "cloudinary/media-editing"
Usage
Setup
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure with CLOUDINARY_URL $config = Cloudinary\Configuration::getDefaultConfiguration() ->setCloudinaryUrl('cloudinary://key:secret@cloud_name');
Create Media Source
Example of how to add Media Storage, in this case a new media source:
$apiInstance = new Cloudinary\MediaDelivery\Api\MediaSourceApi(null, $deliveryConfig); // Payload to create the Media Source $mediaSourceCreatePayload = [ "display_name" => "my_media_source", "source_type" => "s3", "config" => [ "s3_bucket_name" => "my_bucket", "s3_bucket_folder" => "my_bucket_folder", "s3_access_key" => "123456789", "s3_secret_key" => "123456789", "s3_uri_template" => "s3://my_bucket/images/{{vars.signature}}/{{fwd_key}}", ], ]; try { $result = $apiInstance->createMediaSource($mediaSourceCreatePayload); print_r($result); } catch (Exception $e) { echo 'Exception when calling MediaSourceApi->createMediaSource: ', $e->getMessage(), PHP_EOL; }
Transform and Store
Example of how to transform and store an asset:
$apiInstance = new TransformAndStoreApi(null, $config); $mediaSource = new MediaConnectorInstance(); $mediaSource->setId("11fcd4a3b294515067f1266c7e7f0422")->setFwdKey("sample"); $mediaTarget = new MediaConnectorInstance(); $mediaTarget->setId("33832c937c251b8566e4210736cec544")->setFwdKey("new_sample"); $transformRequest = new TransformRequest(); $transformation = new TransformationDescriptor(); $transformation->setCanonicalTransformation("c_scale,w_500"); $transformRequest->setInputType("media_source") ->setMediaSource($mediaSource) ->setMediaTarget($mediaTarget) ->setTransformationDescriptor($transformation); try { $result = $apiInstance->transformAndStore($transformRequest); print_r($result); } catch (\Exception $e) { echo 'Exception when calling TransformAndStoreApi->transformAndStore: ', $e->getMessage(), PHP_EOL; }
Cache warmup
Example of how to perform a cache warmup:
$apiInstance = new Cloudinary\Api\CacheApi(null, $config); $cacheWarmupRequestPayload = new \Cloudinary\MediaDelivery\Model\CacheWarmupRequestPayload(); // \Cloudinary\MediaDelivery\Model\CacheWarmupRequestPayload | Payload to warm up the cache $cacheWarmupRequestPayload->setUrl("<your url>"); // $cacheWarmupRequestPayload->setUrl("https://<cloud_name>.media.cloudinary.net/image/upload/c_scale,w_500/sample"); try { $result = $apiInstance->warmup($cacheWarmupRequestPayload); print_r($result); } catch (Exception $e) { echo 'Exception when calling CacheApi->warmup: ', $e->getMessage(), PHP_EOL; }
Get Help
- Open a Github issue (for issues related to the SDK)
- Open a support ticket (for issues related to your account)
About Cloudinary
Cloudinary is a powerful media API for websites and mobile apps alike, Cloudinary enables developers to efficiently manage, transform, optimize, and deliver images and videos through multiple CDNs. Ultimately, viewers enjoy responsive and personalized visual-media experiences—irrespective of the viewing device.
Additional Resources
- Cloudinary Transformation and REST API References: Comprehensive references, including syntax and examples for all SDKs.
- MediaJams.dev: Bite-size use-case tutorials written by and for Cloudinary Developers
- DevJams: Cloudinary developer podcasts on YouTube.
- Cloudinary Academy: Free self-paced courses, instructor-led virtual courses, and on-site courses.
- Code Explorers and Feature Demos: A one-stop shop for all code explorers, Postman collections, and feature demos found in the docs.
- Cloudinary Roadmap: Your chance to follow, vote, or suggest what Cloudinary should develop next.
- Cloudinary Facebook Community: Learn from and offer help to other Cloudinary developers.
- Cloudinary Account Registration: Free Cloudinary account registration.
- Cloudinary Website
License
Released under the MIT license See the LICENSE file for details.