function ImageStyle::addExtension
Same name in other branches
- 9 core/modules/image/src/Entity/ImageStyle.php \Drupal\image\Entity\ImageStyle::addExtension()
- 10 core/modules/image/src/Entity/ImageStyle.php \Drupal\image\Entity\ImageStyle::addExtension()
- 11.x core/modules/image/src/Entity/ImageStyle.php \Drupal\image\Entity\ImageStyle::addExtension()
Adds an extension to a path.
If this image style changes the extension of the derivative, this method adds the new extension to the given path. This way we avoid filename clashes while still allowing us to find the source image.
Parameters
string $path: The path to add the extension to.
Return value
string The given path if this image style doesn't change its extension, or the path with the added extension if it does.
1 call to ImageStyle::addExtension()
- ImageStyle::getPathToken in core/
modules/ image/ src/ Entity/ ImageStyle.php - Generates a token to protect an image style derivative.
File
-
core/
modules/ image/ src/ Entity/ ImageStyle.php, line 499
Class
- ImageStyle
- Defines an image style configuration entity.
Namespace
Drupal\image\EntityCode
protected function addExtension($path) {
$original_extension = pathinfo($path, PATHINFO_EXTENSION);
$extension = $this->getDerivativeExtension($original_extension);
if ($original_extension !== $extension) {
$path .= '.' . $extension;
}
return $path;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.