AI 1 сар өмнө
parent
commit
22819b70cf

+ 8 - 0
app/JsonRpc/NewsService.php

@@ -284,11 +284,15 @@ class NewsService implements NewsServiceInterface
             unset($articleData['content']);
             unset($articleData['content']);
             //自动处理缩略图、关键字、描述
             //自动处理缩略图、关键字、描述
             if ($articleData['imgurl'] == '') {
             if ($articleData['imgurl'] == '') {
+                //如果没有图,设置level=0
+                $articleData['level'] = '[0]';
                 //content中提取图片第一个图,正则提取
                 //content中提取图片第一个图,正则提取
                 $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
                 $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
                 preg_match_all($reg, $data['content'], $matches);
                 preg_match_all($reg, $data['content'], $matches);
                 if (isset($matches[1][0])) {
                 if (isset($matches[1][0])) {
                     $articleData['imgurl'] = $matches[1][0];
                     $articleData['imgurl'] = $matches[1][0];
+                    //如果有图,设置level=3
+                    $articleData['level'] = '[3]';
                 }
                 }
             }
             }
             if ($articleData['keyword'] == '') {
             if ($articleData['keyword'] == '') {
@@ -427,11 +431,15 @@ class NewsService implements NewsServiceInterface
             unset($articleData['pid']);
             unset($articleData['pid']);
             //自动处理缩略图、关键字、描述
             //自动处理缩略图、关键字、描述
             if ($articleData['imgurl'] == '') {
             if ($articleData['imgurl'] == '') {
+                //如果没有图,设置level=0
+                $articleData['level'] = '[0]';
                 //content中提取图片第一个图,正则提取
                 //content中提取图片第一个图,正则提取
                 $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
                 $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
                 preg_match_all($reg, $data['content'], $matches);
                 preg_match_all($reg, $data['content'], $matches);
                 if (isset($matches[1][0])) {
                 if (isset($matches[1][0])) {
                     $articleData['imgurl'] = $matches[1][0];
                     $articleData['imgurl'] = $matches[1][0];
+                    //如果有图,设置level=3
+                    $articleData['level'] = '[3]';
                 }
                 }
             }
             }
             if ($articleData['keyword'] == '') {
             if ($articleData['keyword'] == '') {