Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ImageStyle.php

function 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 515

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal