Cloudinary Blog

Introducing a complete and modern UI widget for cloud based image uploading

Introducing a new cloud based image upload UI widget

Many websites and mobile applications support user uploaded images and other files. This requires a service to receive and process the uploads, store them safely, manipulate them to match the website or app’s design, and deliver them to your users. This also requires a user interface within your site or app that allows users to easily upload images.  

At Cloudinary, we have been taking care of the entire image management pipeline from the time our service was launched: from an upload API, to cloud storage via our rich set of image manipulation capabilities, to optimized CDN delivery.

Following our customers’ requests, we wanted to create an out-of-the-box complete UI solution that allows image uploading directly from browsers to Cloudinary. This includes UI features, like drag & drop, progress indications, interactive cropping, and preview thumbnails, that are similar to what you can also find in modern web applications, such as Gmail and Facebook, all with a single line of code. And so, we are very excited to introduce Cloudinary's new upload widget.

Cloudinary's upload widget

By adding a single line of JavaScript code to your site, you will have a complete modern UI, allowing users to interactively upload images and any other files to the cloud directly from their web browsers. We provide a fast, rich, and modern UI, that enables users to perform a wide variety of tasks.

For example, you can select one or more files from your local computer; drag & drop images; import files from remote URLs; capture photos using a webcam; and display client-side previews immediately after selecting an image, before it is uploaded to Cloudinary.

Additionally, we indicate upload progress, handle errors, support interactive cropping, and allow various types of image validation and processing. For example, we provide maximum file size validation and scaling down images prior to uploading in order to suit the given dimensions.

Upload widget in progress

Click the blue button below to try out our live upload widget that uploads images directly to the cloud.

How-to integrate our widget into your site

If you still don’t have an account with us, we invite you to create your own Cloudinary account for free. In order to use the widget, you need to enable direct unsigned uploading in your account. You will need your Cloudinary account’s cloud name as well as your upload preset name in order to use the widget. Next, simply include a short JavaScript code, which is quickly delivered via CDN, and add a single line of code to your site in order to open the widget. For example:

Copy to clipboard
<script src="//widget.cloudinary.com/global/all.js" type="text/javascript"/>  

<script type="text/javascript">  
  ...
  cloudinary.openUploadWidget({ cloud_name: 'demo', upload_preset: 'a5vxnzbp'}, 
    function(error, result) {  ...  });
  ...
</script>

When the widget is open, your users can select a file that will be directly uploaded to your Cloudinary account. Then an identifier (public ID) is assigned to the uploaded image and your web page is updated with the image’s public ID using a callback method. That will make it possible to later reference the uploaded image and generate dynamic manipulation and delivery URLs. For example, below you can see how we have created a 150x150 face detection based thumbnails with rounded corners using an uploaded image’s public ID.

Ruby:
Copy to clipboard
cl_image_tag("brahghhk8di0ypfrlu7k.jpg", :width=>150, :height=>150, :gravity=>"face", :radius=>50, :crop=>"thumb")
PHP v1:
Copy to clipboard
cl_image_tag("brahghhk8di0ypfrlu7k.jpg", array("width"=>150, "height"=>150, "gravity"=>"face", "radius"=>50, "crop"=>"thumb"))
PHP v2:
Copy to clipboard
(new ImageTag('brahghhk8di0ypfrlu7k.jpg'))
  ->resize(Resize::thumbnail()->width(150)->height(150)->gravity(Gravity::focusOn(FocusOn::face())))
  ->roundCorners(RoundCorners::byRadius(50));
Python:
Copy to clipboard
CloudinaryImage("brahghhk8di0ypfrlu7k.jpg").image(width=150, height=150, gravity="face", radius=50, crop="thumb")
Node.js:
Copy to clipboard
cloudinary.image("brahghhk8di0ypfrlu7k.jpg", {width: 150, height: 150, gravity: "face", radius: 50, crop: "thumb"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().width(150).height(150).gravity("face").radius(50).crop("thumb")).imageTag("brahghhk8di0ypfrlu7k.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('brahghhk8di0ypfrlu7k.jpg', {width: 150, height: 150, gravity: "face", radius: 50, crop: "thumb"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("brahghhk8di0ypfrlu7k.jpg", {width: 150, height: 150, gravity: "face", radius: 50, crop: "thumb"})
React:
Copy to clipboard
<Image publicId="brahghhk8di0ypfrlu7k.jpg" >
  <Transformation width="150" height="150" gravity="face" radius="50" crop="thumb" />
</Image>
Vue.js:
Copy to clipboard
<cld-image publicId="brahghhk8di0ypfrlu7k.jpg" >
  <cld-transformation width="150" height="150" gravity="face" radius="50" crop="thumb" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="brahghhk8di0ypfrlu7k.jpg" >
  <cl-transformation width="150" height="150" gravity="face" radius="50" crop="thumb">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(150).Height(150).Gravity("face").Radius(50).Crop("thumb")).BuildImageTag("brahghhk8di0ypfrlu7k.jpg")
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().width(150).height(150).gravity("face").radius(50).crop("thumb")).generate("brahghhk8di0ypfrlu7k.jpg");
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setWidth(150).setHeight(150).setGravity("face").setRadius(50).setCrop("thumb")).generate("brahghhk8di0ypfrlu7k.jpg")!, cloudinary: cloudinary)
Face detection based cropped thumbnail

There are various different ways in which you can use the widget. One way is by telling Cloudinary programmatically in your JavaScript code to show the widget. Another way is by rendering a button on your site that opens the widget when it is clicked. In addition, you can tell the widget to automatically create hidden fields in your web page with the uploaded image’s identifiers, or automatically create image thumbnails that are displayed on your site. The upload widget has plenty more options and customizations available. For instance, you can limit the number of files that users are allowed to upload, apply client-side validations that need to be performed regarding file sizes and dimensions, or restrict specific image formats (JPEG or PNG).

For more details, see our documentation page.

Mark areas of interest and crop interactively

One of our widget's interesting features is the ability to allow your users to perform interactive image cropping while their images are uploaded to the cloud. This can be done by setting the cropping parameter to server.

Upload widget with interactive cropping

You can try out a live example by clicking on the following button:

Uploaded images can be stored, as they are, in the cloud together with the coordinates that your users marked as areas of interest. Then, you can use Cloudinary's on-the-fly image manipulation URLs to create thumbnails of the original images while cropping the images based on their marked coordinates. This is done by setting the gravity manipulation parameter to custom. As you can see in the example below, that generates a 200x150 thumbnail of an uploaded image based on the marked coordinates.

Ruby:
Copy to clipboard
cl_image_tag("brahghhk8di0ypfrlu7k.jpg", :width=>200, :height=>150, :gravity=>"custom", :crop=>"thumb")
PHP v1:
Copy to clipboard
cl_image_tag("brahghhk8di0ypfrlu7k.jpg", array("width"=>200, "height"=>150, "gravity"=>"custom", "crop"=>"thumb"))
PHP v2:
Copy to clipboard
(new ImageTag('brahghhk8di0ypfrlu7k.jpg'))
  ->resize(Resize::thumbnail()->width(200)->height(150)
    ->gravity(Gravity::focusOn(FocusOn::custom())));
Python:
Copy to clipboard
CloudinaryImage("brahghhk8di0ypfrlu7k.jpg").image(width=200, height=150, gravity="custom", crop="thumb")
Node.js:
Copy to clipboard
cloudinary.image("brahghhk8di0ypfrlu7k.jpg", {width: 200, height: 150, gravity: "custom", crop: "thumb"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().width(200).height(150).gravity("custom").crop("thumb")).imageTag("brahghhk8di0ypfrlu7k.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('brahghhk8di0ypfrlu7k.jpg', {width: 200, height: 150, gravity: "custom", crop: "thumb"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("brahghhk8di0ypfrlu7k.jpg", {width: 200, height: 150, gravity: "custom", crop: "thumb"})
React:
Copy to clipboard
<Image publicId="brahghhk8di0ypfrlu7k.jpg" >
  <Transformation width="200" height="150" gravity="custom" crop="thumb" />
</Image>
Vue.js:
Copy to clipboard
<cld-image publicId="brahghhk8di0ypfrlu7k.jpg" >
  <cld-transformation width="200" height="150" gravity="custom" crop="thumb" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="brahghhk8di0ypfrlu7k.jpg" >
  <cl-transformation width="200" height="150" gravity="custom" crop="thumb">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(200).Height(150).Gravity("custom").Crop("thumb")).BuildImageTag("brahghhk8di0ypfrlu7k.jpg")
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().width(200).height(150).gravity("custom").crop("thumb")).generate("brahghhk8di0ypfrlu7k.jpg");
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setWidth(200).setHeight(150).setGravity("custom").setCrop("thumb")).generate("brahghhk8di0ypfrlu7k.jpg")!, cloudinary: cloudinary)
Custom cropped thumbnail Original uploaded image

You can also have Cloudinary crop images based on your specified coordinates while uploading before storing them in the cloud using server-side defined upload presets.

Summary

The upload widget is a powerful addition to Cloudinary's end-to-end image management solution. Cloudinary intelligently removes the hassles involved with image uploading, manipulation and delivery, and now with the upload widget, provides you with a dynamic upload UI right on your site.

All it takes is adding a single line of JavaScript code, no additional code is required on the client or server sides. We are very excited to introduce our upload widget and have big plans for further enhancements. As with all of Cloudinary's features, this widget is available in all of our plans, including the free tier with no additional costs. We welcome all feedback in order to make future versions even better.

We invite you to sign up to Cloudinary and start using our upload widget for free today!

Recent Blog Posts

Generate Waveform Images from Audio with Cloudinary

This is a reposting of an article written by David Walsh. Check out his blog HERE!
I've been working a lot with visualizations lately, which is a far cry from your normal webpage element interaction coding; you need advanced geometry knowledge, render and performance knowledge, and much more. It's been a great learning experience but it can be challenging and isn't always an interest of all web developers. That's why we use apps and services specializing in complex tasks like Cloudinary: we need it done quickly and by a tool written by an expert.

Read more
Make All Images on Your Website Responsive in 3 Easy Steps

Images are crucial to website performance, but most still don't implement responsive images. It’s not just about fitting an image on the screen, but also making the the image size relatively rational to the device. The srcset and sizes options, which are your best hit are hard to implement. Cloudinary provides an easier way, which we will discuss in this article.

Read more

The Future of Audio and Video on the Web

By Prosper Otemuyiwa
The Future of Audio and Video on the Web

Web sites and platforms are becoming increasingly media-rich. Today, approximately 62 percent of internet traffic is made up of images, with audio and video constituting a growing percentage of the bytes.

Read more

Embed Images in Email Campaigns at Scale

By Sourav Kundu
Embed Images in Email Campaigns at Scale

tl;dr

Cloudinary is a powerful image hosting solution for email marketing campaigns of any size. With features such as advanced image optimization and on-the-fly image transformation, backed by a global CDN, Cloudinary provides the base for a seamless user experience in your email campaigns leading to increased conversion and performance.

Read more
Build the Back-End For Your Own Instagram-style App with Cloudinary

Github Repo

Managing media files (processing, storage and manipulation) is one of the biggest challenges we encounter as practical developers. These challenges include:

A great service called Cloudinary can help us overcome many of these challenges. Together with Cloudinary, let's work on solutions to these challenges and hopefully have a simpler mental model towards media management.

Read more

Build A Miniflix in 10 Minutes

By Prosper Otemuyiwa
Build A Miniflix in 10 Minutes

Developers are constantly faced with challenges of building complex products every single day. And there are constraints on the time needed to build out the features of these products.

Engineering and Product managers want to beat deadlines for projects daily. CEOs want to roll out new products as fast as possible. Entrepreneurs need their MVPs like yesterday. With this in mind, what should developers do?

Read more