Last updated: Apr-08-2023
Cloudinary's jQuery SDK provides simple, yet comprehensive image and video upload, transformation, optimization, and delivery capabilities that you can implement using code that integrates seamlessly with your existing jQuery application.
Take a look at the following transformation code and the image it delivers:
This relatively simple code performs all of the following on the original front_face.jpg image before delivering it:
- Crop to a 150x150 thumbnail using face-detection gravity to automatically determine the location for the crop
- Round the corners with a 20 pixel radius
- Apply a sepia effect
- Overlay the Cloudinary logo on the southeast corner of the image (with a slight offset). The logo is scaled down to a 50 pixel width, with increased brightness and partial transparency (opacity = 60%)
- Rotate the resulting image (including the overlay) by 10 degrees
- Convert and deliver the image in PNG format (the originally uploaded image was a JPG)
And here's the URL that would be included in the image tag that's automatically generated from the above code:
In a similar way, you can transform a video.
The following code demonstrates defining a file
input field for client-side image or video file upload, and then initializing the input field for use with the
- Build URLs for image and video transformations
- jQuery helper methods for embedding and transforming images, and more
- Direct unsigned file upload from the browser
Install the jQuery library using a package manager:
--save parameter saves the dependency in your
Include the files in your HTML page:
To use the Cloudinary jQuery library you have to configure at least your
cloud_name. You can additionally define a number of optional configuration parameters if relevant. You can find your configuration credentials in the Programmable Media Dashboard of the Cloudinary Console.
- Most functionality implemented on the client side does not require authentication, so only your
cloud_nameis required to be configured, and not your API key or secret. Your API secret should never be exposed on the client side, so if you want to use signed uploads or generate delivery signatures, you'll also need server-side code, for which you can use one of our backend SDKs.
- For backward compatibility reasons, the default value of the optional
secureconfiguration parameter is
false. However, for most modern applications, it's recommended to configure the
trueto ensure that your transformation URLs are always generated as HTTPS.
An instance of the Cloudinary jQuery main class,
CloudinaryJQuery, is already instantiated as
$.cloudinary. Setting the configuration parameters can be done either programmatically in each call to a Cloudinary method or globally using the Cloudinary
config method, for example:
For additional useful code samples and to learn how to integrate Cloudinary with your web applications, take a look at our sample projects for Ruby, PHP and Django. You should also take a look at the following sample project of a dynamic HTML page using Cloudinary's jQuery plugin that performs direct uploading from the browser with uploading progress, an image preview with advanced transformations: