Image Proxy

Uploadcare hosts and delivers your files with a CDN. It implies that you need to upload files first. If you want Uploadcare to deliver files, yet keep them at their current hosting, this is the feature you want to use.

Image Proxy allows you to skip uploading and integrate Uploadcare into your solution with only minor image src modifications. You can use Image Transformations and other features over this delivery mehtod. Older URLs will still work.

Note: Try out Adaptive Delivery first as it's a more advanced feature and it includes Image Proxy functionality. It adapts images to any device automatically with a simple setup. Continue to Image Proxy for a more manual approach.

Setting Up

Open your Uploadcare project's Dashboard and select Delivery from the main menu on the left. Click Connect for Image Proxy.

Step 1. Provide a List of Allowed Domains

Specify the domain names that host your files. Image Proxy will recognize these domains and deliver files successfully. You can add one or more domains in the Image Proxy dialog window.

Step 2. Custom Proxy Endpoint (optional)

By default, Uploadcare creates a proxy endpoint for every project automatically: PUBLIC_KEY.ucr.io (e.g., 88a247b663ba80c3bf6f.ucr.io).

As you can see, a subdomain for the endpoint is your project's Public key. All links start with this URL, so you might want to change it to something readable. Request a custom endpoint domain or subdomain.

Custom endpoint examples:

  • CNAME or subdomain endpoint will look like: mydomain.ucr.io
  • A record or domain endopoint will look like: cdn.mydomain.com

Using Image Proxy

Here's how to use Image Proxy after it's set up.

Step 1. Check How It Works

Add the Image Proxy prefix that contains your Endpoint to a file URL on the allowed domain. For example:

https://yoursite.ucr.io/ + https://yoursite.com/assets/image.jpg =
https://yoursite.ucr.io/https://yoursite.com/assets/image.jpg

After that, image.jpg will be delivered via Uploadcare CDN. The original file will remain at its original place, so that older references will work as well.

Step 2. Apply Image Transformations

You can apply transformations to images by adding one of the respective URL Directives between the prefix and media URL.

This CDN operation will resize image.jpg to 500 px in width by adding -/preview/-/resize/500x/:

https://yoursite.ucr.io/-/preview/-/resize/500x/https://yoursite.com/assets/image.jpg

As a result, image.jpg will be resized and delivered with Uploadcare CDN.

Step 3. Add Proxy Prefixes to Your Media

Now you can add prefixes to all images using your IDE or text editing tool. Apply CDN operations when needed.

You can also optimize your responsive image handling workflow and free up some storage space by deleting image versions in different sizes for adaptive layouts.

Uploadcare resizes images on the fly and you don't have to save all versions beforehand. Here's how to generate multires images:

1260 pixels in width:
https://yoursite.ucr.io/-/preview/-/resize/1260x/https://yoursite.com/assets/image.jpg

760 pixels in width:
https://yoursite.ucr.io/-/preview/-/resize/760x/https://yoursite.com/assets/image.jpg

512 pixels in width:
https://yoursite.ucr.io/-/preview/-/resize/512x/https://yoursite.com/assets/image.jpg

Find out more on implementing Responsive Images with Uploadcare in our blog.

Step 4. Check Performance

You can compare page load time and traffic optimization with Uploadcare CDN and without. Use tools like chrome-devtools for local tests. Play around with the image quality and find a sweet spot for the best visual traffic compression results.

Note that the first request for each media file over Image Proxy URL will copy it to Uploadcare CDN. Therefore, there won't be a performance improvement yet. However, once it gets copied to our servers, all subsequent requests will fetch the file from the closest CDN node.

Image Proxy Use Cases

We picked a collection of the most popular Image Proxy use cases. These cases are about optimizing traffic, improving load time, and handling your assets the way you need.

Improve Load Time

Image Proxy fetches your assets and delivers them via Uploadcare CDN. That alone improves load time of your assets because they get served from a CDN node best for your client’s location.

When handling media, Image Proxy provides further load time improvement by letting you cut file sizes at no visual quality loss. With images, that can be done via our Image Transformations feature.

Specifically, take a look at the following on-the-fly operations:

  • format, convert images to WebP, PNG or JPEG. It's recommended to use format/auto
  • quality, adjust image quality.
  • resize, adjust image size.

This set of tools can help accelerate your images up to 9x.

Implement Responsive Images

After you set up delivery with Image Proxy, there's just one step to build a responsive design. Responsive images require that you prepare images in different sizes and later list them in the srcset attribute or the <picture> element.

Check out our blog article on Image Transformations that covers responsive techniques.

Cut Traffic Costs

While accelerating your media improves your conversions, using less bandwidth cuts your traffic costs.

The workflow here is quite the same as in the load time section: you control media formats, quality levels, and dimensions. It helps you get smaller files without any visual quality loss.

Migrate to the Cloud

A possible case is that you already use a File API or cloud storage for your assets. In both cases, it is easy to migrate. Set up Image Proxy, make a list of your asset URLs, and replace thm with their optimized versions.

Your existing media assets may be transformed on-the-fly with the File API. Read more on Image Transformations here in docs. Learn how to use them with Image Proxy.

Possible Errors

Here's a list of errors you might get when using Image Proxy:

[HTTP 400] Domain <yoursite.com> is not registered

You did not register a Image Proxy domain for your sites by dropping us a line at help@uploadcare.com.

[HTTP 400] Domain <yoursite.com> is not allowed

You tried fetching a file from a domain that was not allowed. Check settings or contact us to add the domain as allowed for your account.

[HTTP 400] Failed to parse file URL

Your prefix was added to an invalid URL. Consider checking that URL.

[HTTP 404]

You tried fetching an unreachable file. Consider checking its URL.

[HTTP 502] 'is_ready' timeout

A problem occurred when trying to upload a file to our storage. Try again later and if it didn't help you always can contact us.

Other errors

Since Image Proxy uses the from_url method, you can also get general errors related to the Upload API or specific to the from_url method.