dever 3 роки тому
батько
коміт
fe9cd7e4db

+ 1 - 1
app/collection/database/content.php

@@ -113,7 +113,7 @@ return array
         'pic'     => array
         (
             'type'      => 'varchar-150',
-            'name'      => '封面图-封面图尺寸300*300px,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'name'      => '封面图-封面图尺寸300*300px,如果未上传,则自动使用内容中的图片,自动进行裁剪,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
             'default'   => '',
             'desc'      => '封面图',
             'match'     => 'option',

+ 14 - 2
app/collection/lib/Content.php

@@ -3,6 +3,7 @@
 namespace Collection\Lib;
 
 use Dever;
+use Dever\Support\Img as Handle;
 
 class Content
 {
@@ -13,8 +14,19 @@ class Content
         $content_id = Dever::param('content_id', $data);
 
         if ($content_id) {
-            $update['where_id'] = $content_id;
-            Dever::db('collection/content')->update($update);
+            $content = Dever::db('collection/content')->one($content_id);
+
+            if ($content) {
+                if (!$content['pic']) {
+                    # 如果封面图不存在,就自动生成
+                    $pic = Dever::param('pic', $data);
+                    if ($pic) {
+                        $update['pic'] = Dever::load('upload/view')->get($pic, 'c', 1);
+                    }
+                }
+                $update['where_id'] = $content_id;
+                Dever::db('collection/content')->update($update);
+            }
         }
     }
 

+ 26 - 0
app/collection/src/Pic.php

@@ -6,6 +6,32 @@ use Dever;
 
 class Pic
 {
+    public function com()
+    {
+        $file = 'https://7.shemic.com/1/2020/12/16/156005c5baf40ff51a327f1c34f2975b.jpg';
+        $data = Dever::load('upload/view')->get($file, 'c', 1);
+        $dest = $data . '&time=' . time();
+
+        echo '<img src="'.$dest.'">';die;
+        //文件名
+        $filename = 'test';
+        //模板key
+        $templateKey = 'collection';
+        //模块数据包:数组key值为模块的key,数组value为文字或者图片
+        $modelSet = array
+        (
+            'name' => '放得开附近的放开就',
+        );
+        //默认值为2,如果值为1,则每次都重新生成图片,否则只生成一次
+        $update = 1;
+        $img = Dever::load('poster/api')->get($filename, $templateKey, $modelSet, $update);
+
+        $dest = $img . '?time=' . time();
+
+        echo '<img src="'.$dest.'">';die;
+
+        print($img);die;
+    }
 	public function test()
 	{
 		$data = Dever::data() . 'window/';

+ 13 - 14
app/content/database/audio.php

@@ -89,20 +89,6 @@ return array
 			'update'	=> 'textarea',
 		),
 
-		
-        'pic'       => array
-        (
-            'type'      => 'varchar-150',
-            'name'      => '背景图-图片尺寸750*1386px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
-            'default'   => '',
-            'desc'      => '背景图',
-            'match'     => 'option',
-            'update'    => 'image',
-            'key'       => '1',
-            'place'     => '750*1386',
-            'list'      => 'Dever::load("content/lib/manage.pic", "{pic}")',
-        ),
-
         'audio'     => array
         (
             'type'      => 'varchar-800',
@@ -126,6 +112,19 @@ return array
             'match'     => 'is_string',
         ),
 
+        'pic'       => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '背景图-图片尺寸750*1386px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '背景图',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '750*1386',
+            'list'      => 'Dever::load("content/lib/manage.pic", "{pic}")',
+        ),
+
         'color'      => array
         (
             'type'      => 'varchar-10',

+ 12 - 13
app/content/database/audio_comment.php

@@ -128,19 +128,6 @@ return array
             //'update'  => 'textarea',
         ),
 
-        
-        'pic'       => array
-        (
-            'type'      => 'varchar-150',
-            'name'      => '封面图-图片尺寸750*422px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
-            'default'   => '',
-            'desc'      => '封面图',
-            'match'     => 'option',
-            'update'    => 'image',
-            'key'       => '1',
-            'place'     => '750*422',
-        ),
-
         'audio'     => array
         (
             'type'      => 'varchar-800',
@@ -164,6 +151,18 @@ return array
             'match'     => 'is_string',
         ),
 
+        'pic'       => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '封面图-图片尺寸750*422px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '封面图',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '750*422',
+        ),
+
         'content'       => array
         (
             'type'      => 'text-255',

+ 13 - 13
app/content/database/live.php

@@ -127,19 +127,6 @@ return array
             //'update'  => 'textarea',
         ),
 
-        
-        'pic'       => array
-        (
-            'type'      => 'varchar-150',
-            'name'      => '封面图-图片尺寸750*422px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
-            'default'   => '',
-            'desc'      => '封面图',
-            'match'     => 'option',
-            'update'    => 'image',
-            'key'       => '1',
-            'place'     => '750*422',
-        ),
-
         'live'     => array
         (
             'type'      => 'text-255',
@@ -162,6 +149,19 @@ return array
             'place'     => '150',
             'upload'    => 'yun',
             'large'     => true,
+            'cover'     => 'pic',//封面图字段名
+        ),
+
+        'pic'       => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '封面图-封面图根据视频自动生成,也可以手动更改,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '封面图',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '750*422',
         ),
 
         'content'       => array

+ 14 - 15
app/content/database/video.php

@@ -65,19 +65,6 @@ return array
 			//增加预览
 			'preview'	=> true,
 		),
-		
-        'pic'		=> array
-		(
-			'type' 		=> 'varchar-150',
-			'name' 		=> '封面图-不传将自动获取第1帧,图片尺寸750*1386px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
-			'default' 	=> '',
-			'desc' 		=> '封面图',
-			'match' 	=> 'option',
-			'update'	=> 'image',
-			'key' 		=> '1',
-			'place'		=> '750*1386',
-            'list'      => 'Dever::load("content/lib/manage.pic", "{pic}")',
-		),
 
         'video'     => array
         (
@@ -91,10 +78,9 @@ return array
             'place'     => '150',
             'upload'    => 'yun',
             'large'     => true,
+            'cover'     => 'pic',//封面图字段名
         ),
 
-        
-
         'video_info'        => array
         (
             'type'      => 'text-255',
@@ -104,6 +90,19 @@ return array
             'match'     => 'is_string',
         ),
 
+        'pic'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '封面图-封面图自动生成,也可以更改,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '封面图',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '750*1386',
+            'list'      => 'Dever::load("content/lib/manage.pic", "{pic}")',
+		),
+
 		'udate'		=> array
 		(
 			'type' 		=> 'int-11',

+ 14 - 13
app/content/database/video_short.php

@@ -108,19 +108,6 @@ return array
             'update'    => 'radio',
             'option'    => $type,
         ),
-		
-		'pic'		=> array
-		(
-			'type' 		=> 'varchar-150',
-			'name' 		=> '封面图-封面图图片尺寸750*1386px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
-			'default' 	=> '',
-			'desc' 		=> '封面图',
-			'match' 	=> 'option',
-			'update'	=> 'image',
-			'key' 		=> '1',
-			'place'		=> '750*1386',
-			'list'		=> '"<img src=\"{pic}\" class=\"dever-pic\" width=\"150\" \/>"',
-		),
 
         'video'     => array
         (
@@ -134,6 +121,20 @@ return array
             'place'     => '150',
             'upload'    => 'yun',
             'large'     => true,
+            'cover'     => 'pic',//封面图字段名
+        ),
+
+        'pic'       => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '封面图-封面图自动生成,也可以更改,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '封面图',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '750*1386',
+            'list'      => '"<img src=\"{pic}\" class=\"dever-pic\" width=\"150\" \/>"',
         ),
 
         'udate'		=> array