|
@@ -20,4 +20,25 @@ class View
|
|
|
return $local;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ # 从内容中解析文件
|
|
|
+ public function file($content, $domain, $local = false)
|
|
|
+ {
|
|
|
+ $content = preg_replace_callback('/[0-9a-zA-Z\-\\/]+(\.jpeg|\.jpg|\.png|\.gif|\.mp3|\.mp4|\.aov|\.m4a)/i', function($matches) use($domain, $local)
|
|
|
+ {
|
|
|
+ $file = $matches[0];
|
|
|
+ $file = ltrim($file, '/');
|
|
|
+ if (!strstr($file, 'http')) {
|
|
|
+ $file = $domain . $file;
|
|
|
+ }
|
|
|
+ if ($local) {
|
|
|
+ $upload = Dever::load('save', 'upload')->act($local, $file);
|
|
|
+ if ($upload && isset($upload['url'])) {
|
|
|
+ $file = $upload['url'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $file;
|
|
|
+ }, $content);
|
|
|
+ return $content;
|
|
|
+ }
|
|
|
}
|