You are here

public function RestfulEntityBase::getImageUris in RESTful 7

Get the image URLs based on the configured image styles.

Parameters

array $file_array: The file array.

array $image_styles: The list of image styles to use.

Return value

array The input file array with an extra key for the image styles.

File

plugins/restful/RestfulEntityBase.php, line 1470
Contains RestfulEntityBase.

Class

RestfulEntityBase
An abstract implementation of RestfulEntityInterface.

Code

public function getImageUris(array $file_array, $image_styles) {

  // Return early if there are no image styles.
  if (empty($image_styles)) {
    return $file_array;
  }

  // If $file_array is an array of file arrays. Then call recursively for each
  // item and return the result.
  if (static::isArrayNumeric($file_array)) {
    $output = array();
    foreach ($file_array as $item) {
      $output[] = $this
        ->getImageUris($item, $image_styles);
    }
    return $output;
  }
  $file_array['image_styles'] = array();
  foreach ($image_styles as $style) {
    $file_array['image_styles'][$style] = image_style_url($style, $file_array['uri']);
  }
  return $file_array;
}