public function ImageStylesProvider::buildDerivativeLink in Consumer Image Styles 8.3
Same name and namespace in other branches
- 4.x src/ImageStylesProvider.php \Drupal\consumer_image_styles\ImageStylesProvider::buildDerivativeLink()
Builds a derivative link based on the image URI and the image style.
Parameters
string $uri: The file URI.
\Drupal\image\ImageStyleInterface $image_style: The image style to apply.
Return value
array A structured array that complies with the JSON:API spec for links.
See also
https://jsonapi.org/format/#document-links
File
- src/
ImageStylesProvider.php, line 82
Class
- ImageStylesProvider
- Class ImageStylesProvider.
Namespace
Drupal\consumer_image_stylesCode
public function buildDerivativeLink($uri, ImageStyleInterface $image_style) {
return [
'href' => file_create_url($image_style
->buildUrl($uri)),
'meta' => [
'rel' => [
static::DERIVATIVE_LINK_REL,
],
],
];
}