mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
format_description() support another img bbcode syntax
This commit is contained in:
@@ -95,7 +95,7 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$logFile = getLogFile("seed-points");
|
||||
$logFile = format_description('[img=http://www.baidu.com][img]http://www.baidu.com[/img]');
|
||||
dd($logFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-03-19');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-03-26');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -5631,9 +5631,10 @@ function format_description($description)
|
||||
//匹配不同块
|
||||
$attachPattern = '\[attach\].*\[\/attach\]';
|
||||
$imgPattern = '\[img\].*\[\/img\]';
|
||||
$imgPattern2 = '\[img=.*\]';
|
||||
$urlPattern = '\[url=.*\].*\[\/url\]';
|
||||
$quotePattern = '\[quote.*\].*\[\/quote\]';
|
||||
$pattern = "/($attachPattern)|($imgPattern)|($urlPattern)|($quotePattern)/isU";
|
||||
$pattern = "/($attachPattern)|($imgPattern)|($imgPattern2)|($urlPattern)|($quotePattern)/isU";
|
||||
// $pattern = "/($attachPattern)|($imgPattern)|($urlPattern)/isU";
|
||||
$delimiter = '{{{}}}';
|
||||
$description = preg_replace_callback($pattern, function ($matches) use ($delimiter) {
|
||||
@@ -5660,6 +5661,14 @@ function format_description($description)
|
||||
'url' => $matches[1]
|
||||
]
|
||||
];
|
||||
} elseif (preg_match('/\[img=(.*)\]/isU', $item, $matches)) {
|
||||
//是否图片
|
||||
$results[] = [
|
||||
'type' => 'image',
|
||||
'data' => [
|
||||
'url' => $matches[1]
|
||||
]
|
||||
];
|
||||
} elseif (preg_match('/\[url=(.*)\](.*)\[\/url\]/isU', $item, $matches)) {
|
||||
$results[] = [
|
||||
'type' => 'url',
|
||||
|
||||
Reference in New Issue
Block a user