You are here

public function ImageReplaceDatabaseStorage::get in Image Replace 8

Determine replacement image uri for the given original filename.

Parameters

string $target_style: The target image style name.

string $target_uri: The uri of the image for which to find a replacement.

Return value

string|null The replacement uri when a mapping for the given uri/style combination exists.

Overrides ImageReplaceStorageInterface::get

File

src/ImageReplaceDatabaseStorage.php, line 32

Class

ImageReplaceDatabaseStorage
Defines a class for image_replace database storage operations.

Namespace

Drupal\image_replace

Code

public function get($target_style, $target_uri) {
  $target_uri_hash = hash('sha256', $target_uri);
  return $this->database
    ->select('image_replace')
    ->fields('image_replace', [
    'replacement_uri',
  ])
    ->condition('target_style', $target_style)
    ->condition('target_uri_hash', $target_uri_hash)
    ->execute()
    ->fetchField();
}