public static function BackgroundImageCssController::imageStyleUrl in Background Image 2.x
Same name and namespace in other branches
- 8 src/Controller/BackgroundImageCssController.php \Drupal\background_image\Controller\BackgroundImageCssController::imageStyleUrl()
- 2.0.x src/Controller/BackgroundImageCssController.php \Drupal\background_image\Controller\BackgroundImageCssController::imageStyleUrl()
Duplication of _responsive_image_image_style_url().
This is needed so this module does not have to provide a hard dependency on the responsive_image module.
Parameters
string $style_name: The style name to use.
string $path: The path of the image file.
Return value
string The image style URL.
Deprecated
in 8.x-1.4, will be removed in 8.x-2.0. Use \Drupal\background_image\BackgroundImageInterface::getImageUrl() instead.
File
- src/
Controller/ BackgroundImageCssController.php, line 305
Class
- BackgroundImageCssController
- Defines a controller to serve image styles.
Namespace
Drupal\background_image\ControllerCode
public static function imageStyleUrl($style_name, $path) {
if ($style_name == '_empty image_') {
// The smallest data URI for a 1px square transparent GIF image.
// http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
return 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
}
$entity = ImageStyle::load($style_name);
if ($entity instanceof ImageStyle) {
return file_url_transform_relative($entity
->buildUrl($path));
}
return file_url_transform_relative(file_create_url($path));
}