$remote_thumbnail_url =
$resource->
getThumbnailUrl();
if (!
$remote_thumbnail_url) { return NULL;
} // Use the configured directory to store thumbnails. The directory can
// contain basic (i.e., global) tokens. If any of the replaced tokens
// contain HTML, the tags will be removed and XML entities will be decoded.
$configuration =
$this->
getConfiguration();
$directory =
$configuration['thumbnails_directory'
];
$directory =
$this->token->
replace($directory);
$directory = PlainTextOutput::
renderFromHtml($directory);
// The local thumbnail doesn't exist yet, so try to download it. First,
// ensure that the destination directory is writable, and if it's not,
// log an error and bail out.
if (!
$this->fileSystem->
prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS
)) { $this->logger->
warning('Could not prepare thumbnail destination directory @dir for oEmbed media.',
[ '@dir' =>
$directory,
]);
return NULL;
}