ahh, that's exactly what I needed! Thanks.
I have black and white versions of all my thumbs saved in the same directory as the full color thumbs.. with filenames ending with "-bw.jpg.jpg" - so now my gallery thumbnails are displayed in black and white and rollover to color versions of the same image.
in:
/administrator/components/com_rsgallery2/config.rsgallery2.php
..I duplicated function getThumb and changed it to:
function getThumbRollover($catid, $height = 0, $width = 0,$class = "") {
global $Itemid, $database, $mosConfig_live_site;
//Setting attributes for image tag
$imgatt="";
if ($height > 0) $imgatt .= " height=\"$height\" ";
if ($width > 0) $imgatt .=" width=\"$width\" ";
if ($class != "")
$imgatt .=" class=\"$class\" ";
else
$imgatt.=" class=\"rsg2-galleryList-thumb\" ";
//If no thumb, show default image.
if ( galleryUtils::getFileCount($catid) == 0 ) {
$thumb_html = "<img $imgatt src=\"".$mosConfig_live_site."/components/com_rsgallery2/images/no_pics.gif\" alt=\"No pictures in gallery\" />";
} else {
//Select thumb setting for specific gallery("Random" or "Specific thumb")
$sql = "SELECT thumb_id FROM #__rsgallery2_galleries WHERE id = '$catid'";
$database->setQuery($sql);
$thumb_id = $database->loadResult();
$list = galleryUtils::getChildList( $catid );
if ( $thumb_id == 0 ) {
//Random thumbnail
$sql = "SELECT name FROM #__rsgallery2_files WHERE gallery_id IN ($list) AND published=1 ORDER BY rand() LIMIT 1";
$database->setQuery($sql);
$thumb_name = $database->loadResult();
} else {
//Specific thumbnail
$thumb_name = galleryUtils::getFileNameFromId($thumb_id);
}
$thumby = imgUtils::getImgThumb($thumb_name);
$thumbles = galleryUtils::cutString($thumby);
$thumb_html = "<div class=\"img-shadow\"><a href=\"".$this->url."\" onmouseout=\"MM_swapImgRestore()\"
onmouseover=\"MM_swapImage('".$thumb_name."','','".$thumby."',1)\"><img $imgatt src=\"".$thumbles."-bw.jpg.jpg\" alt=\"$thumb_name\" id=\"$thumb_name\" name=\"$thumb_name\" /></a></div>";
}
return $thumb_html;
}
..and added a new function:
function cutString($str, $amount = 8, $dir = "right") {
if(($n = strlen($str)) > 0) {
if($dir == "right") {
$start = 0;
$end = $n-$amount;
} elseif( $dir == "left") {
$start = $amount;
$end = $n;
}
return substr($str, $start, $end);
} else return false;
}
then I changed the definition of "thumbHTML" in:
/administrator/components/com_rsgallery2/includes/gallery.class.php
from:
$this->thumbHTML = "<div class=\"img-shadow\"><a href=\"".$this->url."\">".galleryUtils::getThumb( $this->get('id'),0,0,"" )."</a></div>";
to:
$this->thumbHTML = galleryUtils::getThumbRollover( $this->get('id'),0,0,"" );
I'm using the Macromedia rollover functions in the Joomla html template:
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
Thanks Chef Groovy!