public static function ResourceFieldEntity::getImageUris in RESTful 7.2
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.
Overrides ResourceFieldEntityInterface::getImageUris
File
- src/
Plugin/ resource/ Field/ ResourceFieldEntity.php, line 862 - Contains \Drupal\restful\Plugin\resource\Field\ResourceFieldEntity
Class
- ResourceFieldEntity
- Class ResourceFieldEntity.
Namespace
Drupal\restful\Plugin\resource\FieldCode
public static 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[] = static::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;
}