Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
TYPO3
sg_youtube
Commits
c1d466f8
Commit
c1d466f8
authored
Apr 19, 2022
by
Stefan Galinski
🎮
Browse files
[BUGFIX] Fix warnings if the external URL download isn't working for the cached image service
parent
6a50d12d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Classes/Service/CachedImageService.php
View file @
c1d466f8
...
...
@@ -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
]);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment