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 {
$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]);
}
......
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