function ImageStyle::buildUri
Same name in other branches
- 9 core/modules/image/src/Entity/ImageStyle.php \Drupal\image\Entity\ImageStyle::buildUri()
- 8.9.x core/modules/image/src/Entity/ImageStyle.php \Drupal\image\Entity\ImageStyle::buildUri()
- 10 core/modules/image/src/Entity/ImageStyle.php \Drupal\image\Entity\ImageStyle::buildUri()
Overrides ImageStyleInterface::buildUri
2 calls to ImageStyle::buildUri()
- ImageStyle::buildUrl in core/
modules/ image/ src/ Entity/ ImageStyle.php - Returns the URL of this image derivative for an original image path or URI.
- ImageStyle::flush in core/
modules/ image/ src/ Entity/ ImageStyle.php - Flushes cached media for this style.
File
-
core/
modules/ image/ src/ Entity/ ImageStyle.php, line 178
Class
- ImageStyle
- Defines an image style configuration entity.
Namespace
Drupal\image\EntityCode
public function buildUri($uri) {
$source_scheme = $scheme = StreamWrapperManager::getScheme($uri);
$default_scheme = $this->fileDefaultScheme();
if ($source_scheme) {
$path = StreamWrapperManager::getTarget($uri);
// The scheme of derivative image files only needs to be computed for
// source files not stored in the default scheme.
if ($source_scheme != $default_scheme) {
$class = $this->getStreamWrapperManager()
->getClass($source_scheme);
$is_writable = NULL;
if ($class) {
$is_writable = $class::getType() & StreamWrapperInterface::WRITE;
}
// Compute the derivative URI scheme. Derivatives created from writable
// source stream wrappers will inherit the scheme. Derivatives created
// from read-only stream wrappers will fall-back to the default scheme.
$scheme = $is_writable ? $source_scheme : $default_scheme;
}
}
else {
$path = $uri;
$source_scheme = $scheme = $default_scheme;
}
return "{$scheme}://styles/{$this->id()}/{$source_scheme}/{$this->addExtension($path)}";
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.