public function ImageReplaceDatabaseStorage::add in Image Replace 8
Add an image replacement mapping.
Parameters
string $target_style: The target image style name.
string $target_uri: The uri of the image for which to set a replacement.
string $replacement_uri: The replacement uri to set for the given uri/style combination.
Overrides ImageReplaceStorageInterface::add
File
- src/
ImageReplaceDatabaseStorage.php, line 45
Class
- ImageReplaceDatabaseStorage
- Defines a class for image_replace database storage operations.
Namespace
Drupal\image_replaceCode
public function add($target_style, $target_uri, $replacement_uri) {
$target_uri_hash = hash('sha256', $target_uri);
return $this->database
->insert('image_replace')
->fields([
'target_style' => $target_style,
'target_uri_hash' => $target_uri_hash,
'replacement_uri' => $replacement_uri,
])
->execute();
}