[Edit] I seem to be getting somewhere.. When I use the 'Parse_Templates' as hook location it works fine on the forum listing page, but not within the forum.
I understand TC might not be able to do this but is there any way to bypass the plug-in requirement of this modification in order to make it work regardless?
I do run a lot of mods on my forum and it's probable that one of them is clashing, but I'm very close to having this work and feel that just a little more and I'll be there :)
[Edit again] OK.. When I disable the parse_templates plug in modification for the Chiplove thumbnails it works fine.. The code for his is a little more complicated than the one for this modification and I would love to run both.. Does anyone have any ideas?
This is the code for the thumbnails hook in:
PHP Code:
#<?
if($vbulletin->options['chip_threadthumb_turn'] AND in_array(THIS_SCRIPT, array('forumdisplay', 'search')))
{
function threadthumbnails_fetch_forums()
{
global $vbulletin;
list($w, $h) = explode(',', $vbulletin->options['chip_threadthumb_sizedefault']);
$lines = preg_split("#(\r\n|\r|\n)#", $vbulletin->options['chip_threadthumb_include']);
if($vbulletin->options['chip_threadthumb_allforum'])
{
foreach( array_keys($vbulletin->forumcache) as $fid)
{
$vbulletin->forumcache[$fid]['thumb_w'] = $w;
$vbulletin->forumcache[$fid]['thumb_h'] = $h;
}
}
foreach($lines as $line)
{
list($fids, $w_h) = explode('|', $line);
if($w_h)
{
list($w, $h) = array_map('intval', explode(',', $w_h));
}
$fids = array_map('intval', explode(',', $fids));
foreach($fids as $fid)
{
if($vbulletin->forumcache[$fid])
{
$vbulletin->forumcache[$fid]['thumb_w'] = $w;
$vbulletin->forumcache[$fid]['thumb_h'] = $h;
}
}
}
if ($exclude = explode(',', $vbulletin->options['chip_threadthumb_exclude']))
{
foreach($exclude as $fid)
{
if($vbulletin->forumcache[$fid]['thumb_w'])
{
unset($vbulletin->forumcache[$fid]['thumb_w']);
}
}
}
if ($exclude_groups = array_map('intval', explode(',', $vbulletin->options['chip_threadthumb_excludegroups'])))
{
if (in_array($vbulletin->userinfo['usergroupid'], $exclude_groups))
{
foreach( array_keys($vbulletin->forumcache) as $fid)
{
unset($vbulletin->forumcache[$fid]['thumb_w']);
}
}
}
}
function threadthumbnails_get_thumbnail($thread, $pagetext = '', $query = false)
{
global $vbulletin;
$thread['thumb'] = $pagetext ? $pagetext : $thread['pagetext'];
$thread['thumb_src'] = '';
$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;
}
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 OR strpos($vbulletin->options['chip_threadthumb_types'], '3') !== false) )
{
//get attach file - image
$attach = $vbulletin->db->query_first("
SELECT attachment.attachmentid, attachment.dateline
FROM ".TABLE_PREFIX."attachment AS attachment
".iif(strpos($vbulletin->options['chip_threadthumb_types'], '3') !== false, "
LEFT JOIN ".TABLE_PREFIX."filedata AS filedata ON (filedata.filedataid = attachment.filedataid)")."
WHERE attachment.contentid = ".$thread['firstpostid']."
".iif(strpos($vbulletin->options['chip_threadthumb_types'], '3') !== false, "AND filedata.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($query AND !$have_thumb)
{
$post = $vbulletin->db->query_first("
SELECT pagetext FROM ".TABLE_PREFIX."post WHERE threadid = $thread[threadid] AND parentid = 0
");
return threadthumbnails_get_thumbnail($thread, $post['pagetext']);
}
if(!$have_thumb AND $vbulletin->options['chip_threadthumb_useavatar'] AND ($thread['useavatar'] OR THIS_SCRIPT == 'search'))
{
if(THIS_SCRIPT == 'search')
{
$useavatar = $vbulletin->db->query_first("
SELECT userid FROM ".TABLE_PREFIX."customavatar WHERE userid = ".$thread['postuserid']."
");
}
if($useavatar OR $thread['useavatar'])
{
return $vbulletin->options['bburl'].'/image.php?' . $vbulletin->session->vars['sessionurl'] . "u=$thread[postuserid]";
}
}
if (!$have_thumb)
{
$thread['thumb_src'] = vB_Template_Runtime::fetchStylevar("imgdir_misc").'/'.$vbulletin->options['chip_threadthumb_noimg'];
}
return $thread['thumb_src'];
}
threadthumbnails_fetch_forums();
if ($vbulletin->forumcache[intval($GLOBALS['forumid'])]['thumb_w'] > 0 OR THIS_SCRIPT == 'search')
{
$template_name = iif(THIS_SCRIPT == 'search', 'search_').'threadbit';
if($vbulletin->options['chip_threadthumb_zoom'])
{
list($zoom_w, $zoom_h) = array_map('intval', explode(',', $vbulletin->options['chip_threadthumb_zoom_wh']));
//add css
$template_hook['headinclude_bottom_css'] .= '
<style type="text/css">
/* Chiplove.9xpro - Thread Thumbnails 2.2 */
#preview{position:absolute;border:1px solid #ccc;background:#333;padding:5px;display:none;color:#fff;}
</style>';
$jquery_lib = '';
if($vbulletin->options['chip_threadthumb_jquerypath'])
{
if(substr($vbulletin->options['chip_threadthumb_jquerypath'], 0, 4) != 'http')
{
$jquery_lib = $vbulletin->options['bburl'].'/clientscript/jquery/'.$vbulletin->options['chip_threadthumb_jquerypath'];
}
else
{
$jquery_lib =& $vbulletin->options['chip_threadthumb_jquerypath'];
}
}
$template_hook['footer_javascript'] .= ($jquery_lib ? '<script type="text/javascript" src="'.$jquery_lib.'"></script>' : '').'
<script type="text/javascript">
/* Chiplove.9xpro - Thread Thumbnails 2.2 */
function imagePreview(){
xOffset = 30;
yOffset = 30;
jQuery("img.preview").hover(function(e){
this.t = this.title;
this.title = "";
var c = (this.t != "") ? "<br/>" + this.t : "";
jQuery("body").append("<p id=\'preview\'><img src=\'"+ this.src +"\' style=\''.iif($zoom_w,"width:{$zoom_w}px;").iif($zoom_h,"width:{$zoom_h}px;").'\' alt=\'Image Preview\' />"+ c +"</p>");
jQuery("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
},
function(){
this.title = this.t;
jQuery("#preview").remove();
});
jQuery("img.preview").mousemove(function(e){
jQuery("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};
function removeTitle() {
jQuery(".threadinfo").attr("title", "");
jQuery(".threadstatus").attr("title", "");
'.iif(THIS_SCRIPT == 'search', 'var items = jQuery("#searchbits").find(".threadbit");
jQuery.each(items, function(k, v){
if(typeof jQuery(items[k]).find("img.preview").attr("src") != "undefined") {
jQuery(items[k]).find(".threadstatus").attr("title","");
jQuery(items[k]).find(".threadinfo").attr("title","");
jQuery(items[k]).find(".threadinfo").attr("title","");
jQuery(items[k]).attr("title","");
}
});').'
}
jQuery(function(){
imagePreview();
setTimeout("removeTitle();", 1000);
});
</script>
';
$vbulletin->templatecache[$template_name] = str_replace(
'<a class="title',
'<a title="\'.$thread[\'preview\'].\'" class="title',
$vbulletin->templatecache[$template_name]
);
}
$vbulletin->templatecache[$template_name] = str_replace(
'$final_rendered .= \'\' . \'></a>',
'$final_rendered .= \'\' . iif($thread[\'thumb_src\'], \' style="height:\'.($vbulletin->forumcache[$thread[\'forumid\']][\'thumb_h\']+8).\'px !important;width:\'.($vbulletin->forumcache[$thread[\'forumid\']][\'thumb_w\']+10).\'px !important;'.$vbulletin->options['chip_threadthumb_cssforthumbnails'].iif(
$vbulletin->options['chip_threadthumb_overwritestatus'], 'padding-left:'.$vbulletin->options['chip_threadthumb_overwritestatus'].'px;', 'background: none !important;'
).'">
<!-- Forum using plugin: Thread Thumbnails 2.0 - Powered by chiplove.9xpro -->
<img class="preview" src="\'.$thread[\'thumb_src\'].\'" style="width:\'.$vbulletin->forumcache[$thread[\'forumid\']][\'thumb_w\'].\'px;height:\'.$vbulletin->forumcache[$thread[\'forumid\']][\'thumb_h\'].\'px;border:1px solid #c8c8c8;background:#fff;padding:2px;display:block;"\').\' /></a>',
$vbulletin->templatecache[$template_name]
);
}
}
|