| |
| | |

CodersClub

 Forgot password?
 Register
Search
View: 4175|Reply: 0
Collapse the left

How to set cover image??

[Copy link]
Post time: 2012-05-28 11:04
| Show all posts |Read mode
Hello every body. I have a question.In discuz, picture mode.

I want to set cover with link image insert from other web. Any link image in thread. How to do it?
Sorry, my english so bad. Please help me.
I think this function but I don't know edit it:
  1. function setthreadcover($pid, $tid = 0, $aid = 0, $countimg = 0, $imgurl = '') {
  2.         global $_G;
  3.         $cover = 0;
  4.         if(empty($_G['uid']) || !intval($_G['setting']['forumpicstyle']['thumbheight']) || !intval($_G['setting']['forumpicstyle']['thumbwidth'])) {
  5.                 return false;
  6.         }

  7.         if(($pid || $aid) && empty($countimg)) {
  8.                 if(empty($imgurl)) {
  9.                         if($aid) {
  10.                                 $attachtable = 'aid:'.$aid;
  11.                                 $attach = C::t('forum_attachment_n')->fetch('aid:'.$aid, $aid, array(1, -1));
  12.                         } else {
  13.                                 $attachtable = 'pid:'.$pid;
  14.                                 $attach = C::t('forum_attachment_n')->fetch_max_image('pid:'.$pid, 'pid', $pid);
  15.                         }
  16.                         if(!$attach) {
  17.                                 return false;
  18.                         }
  19.                         if(empty($_G['forum']['ismoderator']) && $_G['uid'] != $attach['uid']) {
  20.                                 return false;
  21.                         }
  22.                         $pid = empty($pid) ? $attach['pid'] : $pid;
  23.                         $tid = empty($tid) ? $attach['tid'] : $tid;
  24.                         $picsource = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$attach['attachment'];
  25.                 } else {
  26.                         $attachtable = 'pid:'.$pid;
  27.                         $picsource = $imgurl;
  28.                 }

  29.                 $basedir = !$_G['setting']['attachdir'] ? (DISCUZ_ROOT.'./data/attachment/') : $_G['setting']['attachdir'];
  30.                 $coverdir = 'threadcover/'.substr(md5($tid), 0, 2).'/'.substr(md5($tid), 2, 2).'/';
  31.                 dmkdir($basedir.'./forum/'.$coverdir);

  32.                 require_once libfile('class/image');
  33.                 $image = new image();
  34.                 if($image->Thumb($picsource, 'forum/'.$coverdir.$tid.'.jpg', $_G['setting']['forumpicstyle']['thumbwidth'], $_G['setting']['forumpicstyle']['thumbheight'], 2)) {
  35.                         $remote = '';
  36.                         if(getglobal('setting/ftp/on')) {
  37.                                 if(ftpcmd('upload', 'forum/'.$coverdir.$tid.'.jpg')) {
  38.                                         $remote = '-';
  39.                                 }
  40.                         }
  41.                         $cover = C::t('forum_attachment_n')->count_image_by_id($attachtable, 'pid', $pid);
  42.                         if($imgurl && empty($cover)) {
  43.                                 $cover = 1;
  44.                         }
  45.                         $cover = $remote.$cover;
  46.                 } else {
  47.                         return false;
  48.                 }
  49.         }
  50.         if($countimg) {
  51.                 if(empty($cover)) {
  52.                         $thread = C::t('forum_thread')->fetch($tid);
  53.                         $oldcover = $thread['cover'];

  54.                         $cover = C::t('forum_attachment_n')->count_image_by_id('tid:'.$tid, 'pid', $pid);
  55.                         if($cover) {
  56.                                 $cover = $oldcover < 0 ? '-'.$cover : $cover;
  57.                         }
  58.                 }
  59.         }
  60.         if($cover) {
  61.                 C::t('forum_thread')->update($tid, array('cover' => $cover));
  62.                 return true;
  63.         }
  64. }
Copy the Code



You have to log in before you can reply Login | Register

Points Rules

Archive|Mobile|Dark room|CodersClub

Top.Mail.Ru
Top.Mail.Ru

2024-11-21 22:31 GMT+3 , Processed in 0.020236 sec., 9 queries .

Powered by Discuz! X3.4 Release 20230520

© 2001-2024 Discuz! Team.

MultiLingual version, Rev. 4301, © codersclub.org

Quick Reply To Top Return to the list