+ mailTao: add a method to get key-value pairs of image URL and physical file by file ID.

This commit is contained in:
liugang
2024-05-30 16:54:07 +08:00
committed by caoyanyi
parent 009e540732
commit f77e49d270
+28
View File
@@ -61,6 +61,34 @@ class mailTao extends mailModel
return array($toList, $ccList);
}
/**
* 根据文件 ID 获取图片 url 和物理文件的键值对。
* Get key-value pairs of image URL and physical file by file ID.
*
* @param array $matches
* @access public
* @return array
*/
public function getImagesByFileID(array $matches): array
{
if(!isset($matches[2])) return array();
$this->loadModel('file');
$images = array();
foreach($matches[2] as $key => $fileID)
{
if(!$fileID) continue;
$file = $this->file->getByID((int)$fileID);
if(!$file) continue;
if(!in_array($file->extension, $this->config->file->imageExtensions)) continue;
$images[$matches[1][$key]] = $file->webPath;
}
return $images;
}
/**
* 根据路径获取图片 url 和物理文件的键值对。
* Get key-value pairs of image URL and physical file by path.