@@ -112,7 +112,9 @@ public function __invoke(string $html, int $messageId): string
112112 sort ($ htmlImages );
113113 for ($ i = 0 ; $ i < count ($ htmlImages ); ++$ i ) {
114114 if ($ image = $ this ->getTemplateImage ($ templateId , $ htmlImages [$ i ])) {
115- $ content_type = $ this ->mimeMap [strtolower (substr ($ htmlImages [$ i ], strrpos ($ htmlImages [$ i ], '. ' ) + 1 ))];
115+ $ content_type = $ this ->mimeMap [strtolower (
116+ substr ($ htmlImages [$ i ], strrpos ($ htmlImages [$ i ], '. ' ) + 1 )
117+ )];
116118 $ cid = $ this ->addHtmlImage ($ image ->getData (), basename ($ htmlImages [$ i ]), $ content_type );
117119 if (!empty ($ cid )) {
118120 $ html = str_replace (basename ($ htmlImages [$ i ]), "cid: $ cid " , $ html );
@@ -146,6 +148,7 @@ private function getFilesystemImage(string $filename): string
146148 {
147149 //# get the image contents
148150 $ localFile = basename (urldecode ($ filename ));
151+ $ pageRoot = $ this ->configProvider ->getValue (ConfigOption::PageRoot);
149152 if ($ this ->uploadImagesDir ) {
150153 $ imageRoot = $ this ->configProvider ->getValue (ConfigOption::UploadImageRoot);
151154 if (is_file ($ imageRoot .$ localFile )) {
@@ -161,15 +164,17 @@ private function getFilesystemImage(string $filename): string
161164 );
162165
163166 return base64_encode (file_get_contents ($ this ->documentRoot .$ localFile ));
164- } elseif (is_file ($ this ->documentRoot . '/ ' . $ this ->uploadImagesDir . '/image/ ' . $ localFile )) {
167+ } elseif (is_file ($ this ->documentRoot . '/ ' . $ this ->uploadImagesDir . '/image/ ' . $ localFile )) {
165168 $ this ->configManager ->create (
166169 ConfigOption::UploadImageRoot->value ,
167- $ this ->documentRoot . '/ ' . $ this ->uploadImagesDir . '/image/ ' ,
170+ $ this ->documentRoot . '/ ' . $ this ->uploadImagesDir . '/image/ ' ,
168171 false ,
169172 'string ' ,
170173 );
171174
172- return base64_encode (file_get_contents ($ this ->documentRoot .'/ ' .$ this ->uploadImagesDir .'/image/ ' .$ localFile ));
175+ return base64_encode (
176+ file_get_contents ($ this ->documentRoot . '/ ' . $ this ->uploadImagesDir . '/image/ ' . $ localFile )
177+ );
173178 } elseif (is_file ($ this ->documentRoot .'/ ' .$ this ->uploadImagesDir .'/ ' .$ localFile )) {
174179 $ this ->configManager ->create (
175180 ConfigOption::UploadImageRoot->value ,
@@ -178,20 +183,26 @@ private function getFilesystemImage(string $filename): string
178183 'string ' ,
179184 );
180185
181- return base64_encode (file_get_contents ($ this ->documentRoot .'/ ' .$ this ->uploadImagesDir .'/ ' .$ localFile ));
186+ return base64_encode (
187+ file_get_contents ($ this ->documentRoot . '/ ' . $ this ->uploadImagesDir . '/ ' . $ localFile )
188+ );
182189 }
183190 }
184- } elseif (is_file ($ this ->documentRoot . $ this -> configProvider -> getValue (ConfigOption::PageRoot). '/ ' . $ this ->editorImagesDir . '/ ' . $ localFile )) {
191+ } elseif (is_file ($ this ->documentRoot . $ pageRoot . '/ ' . $ this ->editorImagesDir . '/ ' . $ localFile )) {
185192 $ elements = parse_url ($ filename );
186193 $ localFile = basename ($ elements ['path ' ]);
187194
188- return base64_encode (file_get_contents ($ this ->documentRoot .$ this ->configProvider ->getValue (ConfigOption::PageRoot).'/ ' .$ this ->editorImagesDir .'/ ' .$ localFile ));
189- } elseif (is_file ($ this ->documentRoot .$ this ->configProvider ->getValue (ConfigOption::PageRoot).'/ ' .$ this ->editorImagesDir .'/image/ ' .$ localFile )) {
190- return base64_encode (file_get_contents ($ this ->documentRoot .$ this ->configProvider ->getValue (ConfigOption::PageRoot).'/ ' .$ this ->editorImagesDir .'/image/ ' .$ localFile ));
191- } elseif (is_file ('../ ' .$ this ->editorImagesDir .'/ ' .$ localFile )) {
192- return base64_encode (file_get_contents ('../ ' .$ this ->editorImagesDir .'/ ' .$ localFile ));
193- } elseif (is_file ('../ ' .$ this ->editorImagesDir .'/image/ ' .$ localFile )) {
194- return base64_encode (file_get_contents ('../ ' .$ this ->editorImagesDir .'/image/ ' .$ localFile ));
195+ return base64_encode (
196+ file_get_contents ($ this ->documentRoot . $ pageRoot . '/ ' . $ this ->editorImagesDir . '/ ' . $ localFile )
197+ );
198+ } elseif (is_file ($ this ->documentRoot . $ pageRoot . '/ ' . $ this ->editorImagesDir . '/image/ ' . $ localFile )) {
199+ return base64_encode (
200+ file_get_contents ($ this ->documentRoot . $ pageRoot . '/ ' . $ this ->editorImagesDir . '/image/ ' . $ localFile )
201+ );
202+ } elseif (is_file ('../ ' . $ this ->editorImagesDir . '/ ' . $ localFile )) {
203+ return base64_encode (file_get_contents ('../ ' . $ this ->editorImagesDir . '/ ' . $ localFile ));
204+ } elseif (is_file ('../ ' . $ this ->editorImagesDir . '/image/ ' . $ localFile )) {
205+ return base64_encode (file_get_contents ('../ ' . $ this ->editorImagesDir . '/image/ ' . $ localFile ));
195206 }
196207
197208 return '' ;
@@ -241,6 +252,7 @@ private function filesystemImageExists($filename): bool
241252 {
242253 //# find the image referenced and see if it's on the server
243254 $ imageRoot = $ this ->configProvider ->getValue (ConfigOption::UploadImageRoot);
255+ $ pageRoot = $ this ->configProvider ->getValue (ConfigOption::UploadImageRoot);
244256
245257 $ elements = parse_url ($ filename );
246258 $ localFile = basename ($ elements ['path ' ]);
@@ -254,11 +266,11 @@ private function filesystemImageExists($filename): bool
254266 || is_file ($ imageRoot .'/ ' .$ localFile );
255267 } else {
256268 return
257- is_file ($ this ->documentRoot . $ this -> configProvider -> getValue (ConfigOption::PageRoot). '/ ' . $ this ->editorImagesDir . '/image/ ' . $ localFile )
258- || is_file ($ this -> documentRoot . $ this -> configProvider -> getValue (ConfigOption::PageRoot). '/ ' . $ this ->editorImagesDir . '/ ' . $ localFile )
269+ is_file ($ this ->documentRoot . $ pageRoot . '/ ' . $ this ->editorImagesDir . '/image/ ' . $ localFile )
270+ || is_file ($ pageRoot . '/ ' . $ this ->editorImagesDir . '/ ' . $ localFile )
259271 //# commandline
260- || is_file ('../ ' . $ this ->editorImagesDir . '/image/ ' . $ localFile )
261- || is_file ('../ ' . $ this ->editorImagesDir . '/ ' . $ localFile );
272+ || is_file ('../ ' . $ this ->editorImagesDir . '/image/ ' . $ localFile )
273+ || is_file ('../ ' . $ this ->editorImagesDir . '/ ' . $ localFile );
262274 }
263275 }
264276
0 commit comments