Skip to content
Snippets Groups Projects
Commit c1d466f8 authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[BUGFIX] Fix warnings if the external URL download isn't working for the cached image service

parent 6a50d12d
No related branches found
No related tags found
No related merge requests found
...@@ -119,22 +119,24 @@ class CachedImageService { ...@@ -119,22 +119,24 @@ class CachedImageService {
$imageHash = \md5($url); $imageHash = \md5($url);
// check if any kind of image with this hash is already in the cache-directory // check if any kind of image with this hash is already in the cache-directory
$cachedImage = \glob($cachedImageFolderPath . $imageHash . '.*'); $cachedImage = \glob($cachedImageFolderPath . $imageHash . '.*');
$cachedFileWebPath = '';
if (count($cachedImage) <= 0) { if (count($cachedImage) <= 0) {
// if the cache-directory has not been created yet, do so // if the cache-directory has not been created yet, do so
GeneralUtility::mkdir_deep($cachedImageFolderPath); GeneralUtility::mkdir_deep($cachedImageFolderPath);
// copy without file extension for now if (@\copy($url, $cachedImageFolderPath . $imageHash)) {
\copy($url, $cachedImageFolderPath . $imageHash); // copy without file extension for now
$imageType = \exif_imagetype($cachedImageFolderPath . $imageHash); $imageType = \exif_imagetype($cachedImageFolderPath . $imageHash);
// figure out the file extension based on the image's mime-type // figure out the file extension based on the image's mime-type
$cachedFileName = $imageHash . \image_type_to_extension($imageType); $cachedFileName = $imageHash . \image_type_to_extension($imageType);
$cachedFilePath = $cachedImageFolderPath . $cachedFileName; $cachedFilePath = $cachedImageFolderPath . $cachedFileName;
// correct name // correct name
\rename($cachedImageFolderPath . $imageHash, $cachedFilePath); \rename($cachedImageFolderPath . $imageHash, $cachedFilePath);
GeneralUtility::fixPermissions($cachedFilePath); GeneralUtility::fixPermissions($cachedFilePath);
$cachedFileWebPath = PathUtility::getAbsoluteWebPath($cachedFilePath); $cachedFileWebPath = PathUtility::getAbsoluteWebPath($cachedFilePath);
}
} else { } else {
$cachedFileWebPath = PathUtility::getAbsoluteWebPath($cachedImage[0]); $cachedFileWebPath = PathUtility::getAbsoluteWebPath($cachedImage[0]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment