The Image Relay file selector allows you to include Image Relay files in your own sites and web applications without requiring you to code against our API. Users are able to view and search Image Relay content for use on your sites with a familiar Image Relay user interface branded with your colors and logo.

You can include the file selector on your site in a few simple steps.

Step 1.  Get Client ID

First, you must get a developer client id. To do this you log on to your Image Relay account and click My Account in the upper right corner. From there, you select the Developers link, and click Register New Application.

From there, you will be asked for the name of your application and a redirect url. For the File Selector, the Callback URI should be the domain of the website where your file selector will be hosted. For local development you can specify http://localhost:80 or whatever port you are using for development. So, for example, if you were hosting your application at www.example.com, you would enter https://www.example.com in the Callback URI field.

Once you have clicked Register, you will see a screen like the following:

The field that you need for the file selector widget is the Client ID field. This will identify you to Image Relay when you add the widget to your page.

Step 2. Insert Image Relay Javascript

Add the following to the HTML of the page where you want to include the file selector.

<script type="text/javscript" src="https://cdn.imagerelay.com/selector/selector.js"></script>

Step 3. Add Selector Button HTML

Add the HTML snippet below to create a button that will launch the Image Relay file selector.

<div id="imagerelay-selector" data-client-id="12m3hejtzk75surtlhm4idzge2h2y90" data-link-type="embed" data-domain="https://mycompany.imagerelay.com"></div>

The data attributes are as follows:
data-client-id: The client ID obtained from Step 1
data-link-type: The type of quick link you would like back from the file selector is either embed or branded. Embed will give you a direct link to the file, suitable for using in image tags, etc; branded will give you a link to the file wrapped in a view that will display details about the file, from which it can then be downloaded.
data-domain: The URL of your Image Relay portal. For, i.e. https://mycompany.imagerelay.com, where my company is replaced by your custom Image Relay URL name.

This will produce the following button on your site:

4. Attach event handlers using 

Add some javascript to your site to handle the events from the Image Relay selector.js javascript.


  var irSelect = new ImageRelaySelector();

  // handle user selection
  irSelect.success(function(response) {
     console.log(response);
  });

  // handle user cancel
  irSelect.cancel(function() {
    console.log("User clicked cancel or closed the selector.");
  });

Response JSON

If the user successfully selects an asset, the following response will be returned:

Customizing the Button

You don't have to use the preconfigured Image Relay file selector button. You may call the selector javascript API yourself to launch the selector popup as follows:



  var options = {
    clientId: "12m3hejtzk75surtlhm4idzge2h2y90",
    linkType: "embed",
    domain: 'https://dev.imagerelay.com'
  };

  var irSelect = new ImageRelaySelector(options);

  irSelect.success(function(response) {
     console.log(response);
  });

  irSelect.cancel(function() {
    console.log("user clicked cancel");
  });

  // This will launch the popup
  irSelect.launchPopup();


Did this answer your question?