Commit 24bbbd96 authored by Matthias Adrowski's avatar Matthias Adrowski
Browse files

Merge remote-tracking branch 'origin/master' into feature_Upgrade-to-TYPO3-11

parents 5468c8de bd449e47
......@@ -26,6 +26,7 @@
namespace SGalinski\SgYoutube\Service;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
......@@ -108,26 +109,34 @@ class CachedImageService {
$cachedImageFolderPath = GeneralUtility::getFileAbsFileName(
self::CACHED_IMAGES_DIRECTORY . $this->cacheDirectory . '/'
);
// make absolute path, if the $url is a relative path
if (strpos($url, '/') === 0) {
$url = Environment::getPublicPath() . $url;
}
// Create a hash based on the URL to identify the image
$imageHash = \md5($url);
// check if any kind of image with this hash is already in the cache-directory
$cachedImage = \glob($cachedImageFolderPath . $imageHash . '.*');
$cachedFileWebPath = '';
if (count($cachedImage) <= 0) {
// if the cache-directory has not been created yet, do so
GeneralUtility::mkdir_deep($cachedImageFolderPath);
// copy without file extension for now
\copy($url, $cachedImageFolderPath . $imageHash);
$imageType = \exif_imagetype($cachedImageFolderPath . $imageHash);
if (@\copy($url, $cachedImageFolderPath . $imageHash)) {
// copy without file extension for now
$imageType = \exif_imagetype($cachedImageFolderPath . $imageHash);
// figure out the file extension based on the image's mime-type
$cachedFileName = $imageHash . \image_type_to_extension($imageType);
$cachedFilePath = $cachedImageFolderPath . $cachedFileName;
// figure out the file extension based on the image's mime-type
$cachedFileName = $imageHash . \image_type_to_extension($imageType);
$cachedFilePath = $cachedImageFolderPath . $cachedFileName;
// correct name
\rename($cachedImageFolderPath . $imageHash, $cachedFilePath);
GeneralUtility::fixPermissions($cachedFilePath);
$cachedFileWebPath = PathUtility::getAbsoluteWebPath($cachedFilePath);
// correct name
\rename($cachedImageFolderPath . $imageHash, $cachedFilePath);
GeneralUtility::fixPermissions($cachedFilePath);
$cachedFileWebPath = PathUtility::getAbsoluteWebPath($cachedFilePath);
}
} else {
$cachedFileWebPath = PathUtility::getAbsoluteWebPath($cachedImage[0]);
}
......
......@@ -4,7 +4,7 @@
"description": "Embed YouTube Videos of a Playlist or Channel",
"homepage": "https://www.sgalinski.de",
"license": "GPL-2.0-or-later",
"version": "5.0.0-dev",
"version": "4.8.2",
"require": {
"typo3/cms-core": "^10.4.0 || ^11.5.0",
"sgalinski/project-theme-lightbox": "^2.0.0"
......
......@@ -36,7 +36,7 @@ $EM_CONF['sg_youtube'] = [
'uploadfolder' => '0',
'createDirs' => '',
'clearCacheOnLoad' => 0,
'version' => '5.0.0-dev',
'version' => '4.8.2',
'constraints' => [
'depends' => [
'typo3' => '10.4.0-11.5.99',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment