/** * Create the URL for a preview image including a query parameter. * * @param \Drupal\image\Entity\ImageStyle $style * The image style being previewed. * @param \Drupal\file\Entity\File $image * The image being previewed. * @param string $focal_point_value * The focal point being previewed in the format XxY where x and y are the * left and top offsets in percentages. * * @return \Drupal\Core\GeneratedUrl|string * The URL of the preview image. */ protected function buildUrl(ImageStyle $style, File $image, $focal_point_value) { $url = $style->buildUrl($image->getFileUri()); $url .= (strpos($url, '?') !== FALSE ? '&' : '?') . 'focal_point_preview_value=' . $focal_point_value; return $url; }