public static function EmbedButton::convertEncodedDataToImage in Embed 8
Convert image encoded data to a file on the filesystem.
Parameters
array $data: An array of data about the encoded image including:
- uri: The URI of the file.
- data: The base-64 encoded contents of the file.
Return value
string An image file URI.
Overrides EmbedButtonInterface::convertEncodedDataToImage
1 call to EmbedButton::convertEncodedDataToImage()
- EmbedButton::getIconUrl in src/
Entity/ EmbedButton.php - Returns the URL of the button's icon.
File
- src/
Entity/ EmbedButton.php, line 196
Class
- EmbedButton
- Defines the EmbedButton entity.
Namespace
Drupal\embed\EntityCode
public static function convertEncodedDataToImage(array $data) {
if (!is_file($data['uri'])) {
$directory = dirname($data['uri']);
/** @var \Drupal\Core\File\FileSystemInterface $filesystem */
$fileSystem = \Drupal::service('file_system');
$fileSystem
->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
$fileSystem
->saveData(base64_decode($data['data']), $data['uri'], FileSystemInterface::EXISTS_REPLACE);
}
return $data['uri'];
}