@@ -88,32 +88,34 @@ public function __construct(
88
88
*/
89
89
public function removeDeletedImagesFromCache (array $ files )
90
90
{
91
- $ imageArguments = $ this ->presentationConfig
92
- ->getViewConfig (['area ' => \Magento \Framework \App \Area::AREA_FRONTEND ])
93
- ->getMediaAttributes (
94
- 'Magento_Catalog ' ,
95
- Image::MEDIA_TYPE_CONFIG_NODE ,
96
- 'product_page_image_small '
97
- );
91
+ if (count ($ files ) > 0 ) {
92
+ $ imageArguments = $ this ->presentationConfig
93
+ ->getViewConfig (['area ' => \Magento \Framework \App \Area::AREA_FRONTEND ])
94
+ ->getMediaAttributes (
95
+ 'Magento_Catalog ' ,
96
+ Image::MEDIA_TYPE_CONFIG_NODE ,
97
+ 'product_page_image_small '
98
+ );
98
99
99
- $ imageMiscParams = $ this ->imageParamsBuilder ->build ($ imageArguments );
100
+ $ imageMiscParams = $ this ->imageParamsBuilder ->build ($ imageArguments );
100
101
101
- if (isset ($ imageMiscParams ['image_type ' ])) {
102
- unset($ imageMiscParams ['image_type ' ]);
103
- }
102
+ if (isset ($ imageMiscParams ['image_type ' ])) {
103
+ unset($ imageMiscParams ['image_type ' ]);
104
+ }
104
105
105
- $ cacheId = $ this ->encryptor ->hash (
106
- implode ('_ ' , $ this ->convertImageMiscParamsToReadableFormat
107
- ->convertImageMiscParamsToReadableFormat ($ imageMiscParams )),
108
- Encryptor::HASH_VERSION_MD5
109
- );
106
+ $ cacheId = $ this ->encryptor ->hash (
107
+ implode ('_ ' , $ this ->convertImageMiscParamsToReadableFormat
108
+ ->convertImageMiscParamsToReadableFormat ($ imageMiscParams )),
109
+ Encryptor::HASH_VERSION_MD5
110
+ );
110
111
111
- $ catalogPath = $ this ->mediaConfig ->getBaseMediaPath ();
112
+ $ catalogPath = $ this ->mediaConfig ->getBaseMediaPath ();
112
113
113
- foreach ($ files as $ filePath ) {
114
- $ this ->mediaDirectory ->delete (
115
- $ catalogPath . '/cache/ ' . $ cacheId . '/ ' . $ filePath
116
- );
114
+ foreach ($ files as $ filePath ) {
115
+ $ this ->mediaDirectory ->delete (
116
+ $ catalogPath . '/cache/ ' . $ cacheId . '/ ' . $ filePath
117
+ );
118
+ }
117
119
}
118
120
return null ;
119
121
}
0 commit comments