From 210a3e06df0dd027ee7c36eb4e00b5c809d87e6a Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 29 May 2024 16:37:38 +0800 Subject: [PATCH] * mailTao: replace image url by the key-value pairs of image URL and physical file. --- module/mail/tao.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/module/mail/tao.php b/module/mail/tao.php index 9420cf2340..54da249120 100644 --- a/module/mail/tao.php +++ b/module/mail/tao.php @@ -143,18 +143,17 @@ class mailTao extends mailModel * Replace image URL for mail content. * * @param string $body + * @param array $images * @access protected * @return string */ - protected function replaceImageURL(string $body): string + protected function replaceImageURL(string $body, array $images): string { - /* Replace full webPath image for mail. */ - $sysURL = zget($this->config->mail, 'domain', common::getSysURL()); - $readLinkReg = str_replace(array('%fileID%', '/', '.', '?'), array('[0-9]+', '\/', '\.', '\?'), helper::createLink('file', 'read', 'fileID=(%fileID%)', '\w+')); - - $body = preg_replace('/ src="(' . $readLinkReg . ')" /', ' src="' . $sysURL . '$1" ', $body); - $body = preg_replace('/ src="{([0-9]+)(\.(\w+))?}" /', ' src="' . $sysURL . helper::createLink('file', 'read', "fileID=$1", "$3") . '" ', $body); - $body = preg_replace('/config->webRoot . 'data/upload', $body); + foreach($images as $url => $file) + { + if(!$file) continue; + $body = str_replace($url, 'cid:' . basename($file), $body); + } return $body; }