The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Undesired result trying to grab first attachment from thread
From this Mod: https://vborg.vbsupport.ru/showthread.php?t=271131
-- I need this code to always grab the first uploaded file, but for some reason it *sometimes* uses the first uploaded image, but other times it uses other images... Location: threadbit_process Code:
global $forumids_included; if ($vbulletin->options['chip_threadthumb_turn'] AND in_array($foruminfo['forumid'], array_keys((array)$forumids_included))) { $have_thumb = false; //using image of first post + youtube thumbnails if ( strpos($vbulletin->options['chip_threadthumb_types'], '1') !== false ) { if (preg_match('#\[IMG\](.+?)\[\/IMG\]#i', $thread['thumb'], $m)) { $thread['thumb_src'] = $m[1]; $have_thumb = true; } elseif (preg_match('#\[YOUTUBE\]([^\[]+?)\[\/YOUTUBE\]#i', $thread['thumb'], $m)) { $str = preg_replace('#(http.*watch\?v=)?([^"]+?)(&.*)?#', '$2', $m[1]); $thread['thumb_src'] = 'http://i4.ytimg.com/vi/'.$str.'/default.jpg'; $have_thumb = true; } //vb4 elseif (preg_match('#\[video=youtube;([^\]]+?)\]#i', $thread['thumb'], $m)) { $thread['thumb_src'] = 'http://i4.ytimg.com/vi/'.$m[1].'/default.jpg'; $have_thumb = true; } } //using file attach if ( !$have_thumb // have not a thumbnails AND $thread['attach'] > 0 //have attach files AND strpos($vbulletin->options['chip_threadthumb_types'], '2') !== false ) { //get attach file - image $attach = $vbulletin->db->query_first(" SELECT attachment.attachmentid, attachment.dateline FROM ".TABLE_PREFIX."attachment AS attachment WHERE attachment.postid = ".$thread['firstpostid']." AND attachment.extension IN ('png', 'jpg', 'jpeg', 'gif', 'bmp') LIMIT 1 "); if($attach) { $thread['thumb_src'] = $vbulletin->options['bburl'].'/attachment.php?attachmentid='.$attach['attachmentid'].'&thumb=1&d='.$attach['dateline']; $have_thumb = true; } } if($vbulletin->options['chip_threadthumb_showdefault'] && !$have_thumb) { $thread['thumb_src'] = $stylevar['imgdir_misc'].'/'.$vbulletin->options['chip_threadthumb_noimg']; $have_thumb = 1; } if ($have_thumb) { $thread['hasthumb'] = 1; $thread['threadiconpath'] =& $thread['thumb_src']; } unset($thread['thumb']); forumdisplay_query Code:
if($vbulletin->options['chip_threadthumb_turn'] AND THIS_SCRIPT == 'forumdisplay' AND $vbulletin->forumcache["$forumid"]['thumb_w']) { $previewfield .= "thread.firstpostid, post.pagetext AS thumb,"; if(!strpos($previewjoin, 'post AS post')) { $previewjoin .= "\nLEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.firstpostid)\n"; } } Anyone know what might be happening here? |
#2
|
|||
|
|||
I don't follow everything going on there, but it may be that the query in the threadbit_process plugin, under the "//get attach file - image" comment, should have "ORDER BY attachment.dateline ASC", otherwise I think the order is undefined.
|
Благодарность от: | ||
N8 |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|