I am using the Services (7.x-3.7) module to provide a REST API to our website content. However I have a problem with returning images. I am using Scald (7.x-1.1) to manage our media items. This means that when I attempt to GET a node (example.com/rest/node/25592) I get each field for the node in question nicely wrapped in JSON but for the image instead of an image path and file-name I get the Scald ID as follows:

field_event_image: {
und: [1]
0: {
sid: "15775"

How can a client application reference the image path from the SID? I know I can use example.com/atom/15775 but this gives me back a themed node page containing the image - it contains the menu and default theme elements so it is not trivial or efficient to retrieve the image path from the source - though it could be done with some client side parsing. What I am looking for is a means to reference the image path directly using the SID. I am trying to keep the number of API calls to a minimum. Alternatively is there some way to configure the Services module to return the image path?


1 Answer 1


Found a way – this is how to retrieve image url and image html from given sid:

if(isset($vars['node']->field_teaserbild['und'][0]['sid'])) {

    $img = $vars['node']->field_teaserbild['und'][0]['sid'];
    $atom = scald_atom_load($img);
    $image_uri = $atom->base_entity->uri;
    $vars['img_style_url'] = image_style_url('my_img_style', $image_uri); // style_url
    $vars['img_html'] = theme('image_style', array('style_name' => 'my_img_style', 'path' => $image_uri)); // html


Just in case somebody is still hoping for an answer…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.