Images API

The Image API supports the process of uploading and editing images. These images can be used as a splash images for posts, teaser images, social teasers, as well as for other features where photos are required beyond the scope of posts, such as author creation.

Ratios

Every site on RebelMouse can have its own image cropping ratios configured. The configured ratios reflect the desired use and placement of each image.

By default, the following ratios are configured on RebelMouse:

Title Code Sizes
Super Wide 3x1
  • 1200x400
  • 600x200
Wide 2x1
  • 1200x600
  • 600x300
Medium 3x2
  • 1200x800
  • 600x400
Square 1x1
  • 600x600
  • 300x300
Tall 9x16
  • 700x1245
Widescreen 16x9
  • 1245x700

Uploading images

Upload an image and send its contents as a part of an HTTP request body, or send an image URL as part of a JSON document.

POST /api/1.3/images

Parameters

Name Type Description
image_url String A image URL location - Optional
caption String Caption - Optional
photo_credit String Photo credit - Optional
alt String Alt/Title - Optional
link_url String Link’s destination, it wraps image markup with a link element - Optional
title String Link’s title, it renders a title attribute in link - Optional
link_target String If "true" is received, it adds target=”_blank” in image markup - Optional

Note

  • Multiple files can be sent as part of an HTTP request. This can be done if image_url is not used as part of the HTTP request.
  • For requests with “multipart/form-data” content type, files should be named with “file”.

Example with multipart/form-data

POST /api/1.3/images HTTP/1.1
HOST: <domain>
x-rmauth: <api key>
authorization: Basic <base64 encoded credentials>
content-type: multipart/form-data; boundary=----WebKitFormBoundarym59pe8dwmBaESksR
content-length: <content length>

------WebKitFormBoundarym59pe8dwmBaESksR
Content-Disposition: form-data; name="file"; filename="image.png"
Content-Type: image/png

<file content>
------WebKitFormBoundarym59pe8dwmBaESksR--

Note

Files must be named with “file” string.

Response

For a single image:

For multiple images:

The images will all use the same schema and will be returned in the form of an array.

Editing images

Editing an image (in terms of altering its dimensions).

PUT /api/1.3/images/<id>

Parameters

Name Type Description
image_url String A image URL location - Required
manual_image_crops Object Crop setting for resizing image - Optional
caption String Caption - Optional
photo_credit String Photo credit - Optional

Manual Image Crops

This will depend on the ratios configured for each site. The images must be objects whose keys are the ratio codes with the corresponding values containing the following information:

Name Type Description
top Integer Absolute top coordinate
left Integer Absolute left coordinate
height Integer Absolute height coordinate
width Integer Absolute width coordinate
imgHeight Integer Width of the original image
imgWidth Integer Height of the original image

Example

{
     "16x9": {
             "top": 222,
             "left": 0,
             "height": 289,
             "width": 512,
             "imgWidth": 512,
             "imgHeight": 511
     },
     "2x1": {
             "top": 255,
             "left": 0,
             "height": 256,
             "width": 512,
             "imgWidth": 512,
             "imgHeight": 511
     },
     "3x2": {
             "top": 169,
             "left": 0,
             "height": 342,
             "width": 512,
             "imgWidth": 512,
             "imgHeight": 511
     },
     "1x1": {
             "top": 402,
             "left": 0,
             "height": 109,
             "width": 109,
             "imgWidth": 512,
             "imgHeight": 511
     },
     "9x16": {
             "top": 303,
             "left": 0,
             "height": 208,
             "width": 117,
             "imgWidth": 512,
             "imgHeight": 511
     }
}

Response

The response here is the same as when images are uploaded. Only one image can be edited per request.