URLs
GET api.ashx/v2/ui/image.xml (or .json)
Renders resized image HTML for a local or remote image URL with support for server-side resizing and different scale modes.
Request Parameters
Name | Type | Description | Location | Required | Default | Options |
---|---|---|---|---|---|---|
url | string | Url | Query String | Required | ||
maxHeight | int | Maximum height of resulting image | Query String | Required | 100 | |
maxWidth | int | Maximum width of resulting image | Query String | Required | 100 | |
resizeMethod | string | Method to resize. ScaleDown scales the entire image to fit within the boundaries. ZoomAndCrop scales the image as small as possible while still filling the entire width/height boundaries and retaining aspect ratio, resulting in cropping of either the X or Y axis as necessary. | Query String | Optional | ScaleDown | ScaleDown, ZoomAndCrop |
scaleFactor | double | Scale factor to use for high-DPI output | Query String | Optional | 1 | |
outputIsPersisted | bool | When the output is not persisted, direct links to CFS file URLs can be rendered. Otherwise, the generic CFS URL is rendered which results in a redirect. | Query String | Optional | false |
Example Requests
C# REST SDK
This example uses the REST SDK to access the Community REST API within a .Net C# application. In the example, USER_NAME
is the user name of the effective user for the request and OAUTH_CLIENT_ID
and OAUTH_SECRET
are the OAuth client ID and secret, respectively, associated to this application as configured in Administration > Integration > OAuth Clients with the "Client Credentials" grant type enabled. See the documentation for the REST SDK for more details about installation, configuration, and usage options.
var host = new ClientCredentialsRestHost("USER_NAME", "https://mysite.com/", "OAUTH_CLIENT_ID", "OAUTH_SECRET"); var response = host.GetToDynamic(2, "ui/image.json", false, new RestGetOptions { QueryStringParameters = new System.Collections.Specialized.NameValueCollection { { "url", "url" }, { "maxHeight", "6" }, { "maxWidth", "6" } } });
Widget Javascript
This example uses the rest JavaScript API to access the Community REST API within the Community web UI. When accessing the REST API through the javascript API, the effective user is the current contextual user of the web interface.
jQuery.telligent.evolution.get({ url: jQuery.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/ui/image.json', data: { 'url': 'url', 'maxHeight': '6', 'maxWidth': '6' }, success: function(response) { } });
cURL
This example uses the cURL command-line HTTP utility. ENCODED_TOKEN
in the example is the base64-encoded concatenation of the user's API key (created from the user's profile), a colon (:), and the user's user name. Learn more about using the REST API.
curl -H "Rest-User-Token: ENCODED_TOKEN" -X GET https://mysite.com/api.ashx/v2/ui/image.xml?url=url&maxHeight=6&maxWidth=6
Example Responses
XML
<?xml version="1.0" encoding="utf-16"?> <Response> <Html>html</Html> <Errors> <Message>string</Message> <Message>string</Message> </Errors> </Response>
JSON
{ "Html": "html", "Errors": [ "string", "string" ] }