API bundle to get all media representations

I'm back with a new "API bundle question"! I'm trying to get urls for all media representations of an object knowing the objet id. So I've written this bundle:

      array("bundles" => array(
        "ca_objects.preferred_labels.name" => array(),
        "ca_object_representations.media.large.url"  => array(),
         "ca_object_representations.media.original.url"  => array()

And it works! Except that it only returns one object representation, the primary one. I need to get all the object representations not only the "primary"!
Any idea how to achieve this?


  • Ok I've found out that this is linked to a "filterNonPrimaryRepresentations" parameter that could be set to false if we want to get all the representations instead of just the primary one. But is there a way to set this parameter in a web API call? I tried to add this as a get parameter like this:

    $itemClient = new ItemService($this->CAurl, $this->CAuser, $this->CAkey, 'ca_objects','GET'); $itemClient->addGetParameter('filterNonPrimaryRepresentations', 0);

    But it doesnt work. In the meantime I noticed that if I change this filter to false in app/lib/Search/ObjectSearchResult.php line 57, it works, I get all the media representations. But I would like to avoid changing stuff in Providence if possible so I'm still looking for a way to set it in the API call...

  • Hi Lionel,
    did you tried with ca_objects_x_object_representations instead of ca_object_representations?

  • So, I also ran into this or a similar problem a while ago when I was working on a Drupal front end where I needed to get all the image representations. Unfortunately the only work around I was able to find was to use the old REST API. See code below. Hopefully it helps.

    private function getObjectImages($id) {
            $credentials = base64_encode($this->ca_username . ':' . $this->ca_password);
            $options = [
                'method' => 'POST',
                'headers' => [
                    'Authorization' => 'Basic ' . $credentials,
                    'Content-Type'  => "application/x-www-form-urlencoded"
            $url = $this->serviceURL . '/iteminfo/ItemInfo/rest?method=getObjectRepresentations&object_id=' . $id . '&versions[]=original';
            $response = drupal_http_request($url, $options);
            if($response->code == 200) {
                $xml_data = simplexml_load_string($response->data);
                $img_list_obj = $xml_data->getObjectRepresentations;
            if(isset($img_list_obj)) {
                $images = array();
                foreach($img_list_obj as $key => $value) {
                    foreach($value as $key2 => $value2) {
                        $image_url = $value2->urls->original;
                        $image_width = $value2->info->original->WIDTH;
                        $image_height = $value2->info->original->HEIGHT;
                        $image_access = (($value2->access == 0) ? 'Not accessible to public' : 'Accessible to public');
                        if(isset($image_url) && isset($image_width) && isset($image_height)) {
                            $image = new CAImage($image_url, $image_width, $image_height, $image_access);
                            array_push($images, $image);
            return $images;
Sign In or Register to comment.