Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

How to set cover image with other link image in thread??

[复制链接]
manchestersnit 发表于 2012-5-28 16:09:54 | 显示全部楼层 |阅读模式
Hello every body. I have a question.In discuz, picture mode. Because my hosting is low space disk and bandwidth. I can't attachment.


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. }
复制代码
回复

使用道具 举报

supmas 发表于 2012-5-28 16:41:40 | 显示全部楼层
本帖最后由 supmas 于 2013-1-30 17:38 编辑

。。。。。。。。。。。。








回复

使用道具 举报

yuantao19861215 发表于 2012-6-17 14:01:38 | 显示全部楼层
................看不懂
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-9-8 20:33 , Processed in 0.085529 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表