ImageStyle::addExtension

protected ImageStyle::addExtension($path)

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.

File

core/modules/image/src/Entity/ImageStyle.php, line 447

Class

ImageStyle
Defines an image style configuration entity.

Namespace

Drupal\image\Entity

Code

protected function addExtension($path) {
  $original_extension = pathinfo($path, PATHINFO_EXTENSION);
  $extension = $this->getDerivativeExtension($original_extension);
  if ($original_extension !== $extension) {
    $path .= '.' . $extension;
  }
  return $path;
}
doc_Drupal
2016-10-29 09:19:28
Comments
Leave a Comment

Please login to continue.