Index: /extensions/modus/js/thumb.arrange.js
===================================================================
--- /extensions/modus/js/thumb.arrange.js	(revision 27411)
+++ /extensions/modus/js/thumb.arrange.js	(revision 27412)
@@ -15,7 +15,14 @@
 		if (this.elements.length === 0)
 			this.firstThumbIndex = absIndex;
-		if (!$elt.data("w"))
-		{
-			var w=$elt.width(), h=$elt.height();
+		var w,h;
+
+		if (! (w=$elt.data("w")) ) {
+			if ( (w=$elt[0].getAttribute("width")) && (w=parseInt(w)) ) {
+				h=parseInt($elt[0].getAttribute("height"));
+			}
+			else {
+				w=$elt.width();
+				h=$elt.height();
+			}
 			if (h > this.rowHeight) {
 				w = Math.round(w * this.rowHeight/h);
@@ -25,9 +32,12 @@
 				.data("h", h);
 		}
+		else
+			h=$elt.data("h");
+		
 
 		var eltObj = {
 			$elt: $elt,
-			w: $elt.data("w"),
-			h: $elt.data("h")
+			w: w,
+			h: h
 		};
 		this.elements.push(eltObj);
@@ -166,16 +176,17 @@
 
 	reposition: function($img, imgW, imgH, liW, liH) {
-		$img.attr("width", imgW)
-			.attr("height", imgH);
+		/* JQuery .attr and .css functions add too much overhead ...*/
+		var elt = $img[0];
+		elt.setAttribute("width", imgW+"");
+		elt.setAttribute("height", imgH+"");
 
-		$img.closest("li").css( {
-			width: liW+"px",
-			height: liH+"px"
-		});
+		elt = elt.parentNode;//a
+		elt.style.left = Math.round((liW-imgW)/2)+"px";
+		elt.style.top = Math.round((liH-imgH)/2)+"px";
 
-		$img.parent("a").css( {
-			left: Math.round((liW-imgW)/2)+"px",
-			top: Math.round((liH-imgH)/2)+"px"
-		});
+		elt = elt.parentNode;//li
+		elt.style.width = liW+"px";
+		elt.style.height = liH+"px";
+
 	}
 
Index: /extensions/modus/js/thumb.arrange.min.js
===================================================================
--- /extensions/modus/js/thumb.arrange.min.js	(revision 27411)
+++ /extensions/modus/js/thumb.arrange.min.js	(revision 27412)
@@ -1,8 +1,8 @@
 function RVGTLine(a,c){this.elements=[];this.margin=a;this.rowHeight=c;this.maxHeight=0}
-RVGTLine.prototype={width:0,elementsWidth:0,firstThumbIndex:0,add:function(a,c){0===this.elements.length&&(this.firstThumbIndex=c);if(!a.data("w")){var d=a.width(),b=a.height();b>this.rowHeight&&(d=Math.round(d*this.rowHeight/b),b=this.rowHeight);a.data("w",d).data("h",b)}d={$elt:a,w:a.data("w"),h:a.data("h")};this.elements.push(d);d.h>this.maxHeight&&(this.maxHeight=d.h);this.width+=this.margin+d.w;this.elementsWidth+=d.w},clear:function(){this.elements.length&&(this.maxHeight=this.width=this.elementsWidth=
-0,this.elements.length=0)}};
+RVGTLine.prototype={width:0,elementsWidth:0,firstThumbIndex:0,add:function(a,c){0===this.elements.length&&(this.firstThumbIndex=c);var d,b;(d=a.data("w"))?b=a.data("h"):((d=a[0].getAttribute("width"))&&(d=parseInt(d))?b=parseInt(a[0].getAttribute("height")):(d=a.width(),b=a.height()),b>this.rowHeight&&(d=Math.round(d*this.rowHeight/b),b=this.rowHeight),a.data("w",d).data("h",b));d={$elt:a,w:d,h:b};this.elements.push(d);d.h>this.maxHeight&&(this.maxHeight=d.h);this.width+=this.margin+d.w;this.elementsWidth+=
+d.w},clear:function(){this.elements.length&&(this.maxHeight=this.width=this.elementsWidth=0,this.elements.length=0)}};
 function RVGThumbs(a){this.opts=a;this.$thumbs=$("#thumbnails");if(0!=this.$thumbs.length){this.$thumbs.css("text-align","left");this.opts.extraRowHeight=0;1<window.devicePixelRatio?(a=window.devicePixelRatio,this.opts.resizeThreshold=1.01,this.opts.resizeFactor=0.95,this.opts.extraRowHeight=6,this.opts.rowHeight=Math.round(this.opts.rowHeight/a)+this.opts.extraRowHeight):(this.opts.resizeThreshold=1.1,this.opts.resizeFactor=0.8);this.process();var c=this;$(window).on("resize",function(){1<Math.abs(c.$thumbs.width()-
 c.prevContainerWidth)&&c.process()}).on("RVTS_loaded",function(a,b){c.process(b&&c.$thumbs.width()==c.prevContainerWidth?c.prevLastLineFirstThumbIndex:0)});$.isReady||$(document).ready(function(){c.$thumbs.width()<c.prevContainerWidth&&c.process()})}}
 RVGThumbs.prototype={prevContainerWidth:0,prevLastLineFirstThumbIndex:0,process:function(a){a=a?a:0;var c=this.$thumbs.width();this.prevContainerWidth=c;for(var d=$("li>a>img",this.$thumbs),b=new RVGTLine(this.opts.hMargin,this.opts.rowHeight);a<d.length;a++){var e=$(d[a]);b.add(e,a);b.width>=c-1*b.elements.length&&(this.processLine(b,c),b.clear())}b.elements.length&&this.processLine(b,c,!0);this.prevLastLineFirstThumbIndex=b.firstThumbIndex},processLine:function(a,c,d){var b,e,f=a.maxHeight?a.maxHeight:
 a.elements[0].h;a.width/c>this.opts.resizeThreshold?(e=a.elementsWidth/(a.elementsWidth+c-a.width),b=f/(1+(e-1)*this.opts.resizeFactor),b=6*Math.round(b/6),b<f/e&&(b=Math.ceil(f/e),e=this.opts.rowHeight-this.opts.extraRowHeight-b,0<e&&6>e&&(b+=e)),b<f&&(f=b)):d&&(f=Math.min(f,this.opts.rowHeight-this.opts.extraRowHeight));c=a.width-c;d&&(c=0);for(var k=0;k<a.elements.length;k++){var h=a.elements[k];b=h.w;e=h.h;var g;g=k==a.elements.length-1?c:Math.round(c*b/a.elementsWidth);c-=g;a.elementsWidth-=
-b;e>f&&(b=Math.round(b*f/h.h),e=f,g-=h.w-b,d&&(g=0));this.reposition(h.$elt,b,e,b-g,f)}},reposition:function(a,c,d,b,e){a.attr("width",c).attr("height",d);a.closest("li").css({width:b+"px",height:e+"px"});a.parent("a").css({left:Math.round((b-c)/2)+"px",top:Math.round((e-d)/2)+"px"})}};
+b;e>f&&(b=Math.round(b*f/h.h),e=f,g-=h.w-b,d&&(g=0));this.reposition(h.$elt,b,e,b-g,f)}},reposition:function(a,c,d,b,e){a=a[0];a.setAttribute("width",c+"");a.setAttribute("height",d+"");a=a.parentNode;a.style.left=Math.round((b-c)/2)+"px";a.style.top=Math.round((e-d)/2)+"px";a=a.parentNode;a.style.width=b+"px";a.style.height=e+"px"}};
Index: /extensions/modus/themeconf.inc.php
===================================================================
--- /extensions/modus/themeconf.inc.php	(revision 27411)
+++ /extensions/modus/themeconf.inc.php	(revision 27412)
@@ -69,5 +69,5 @@
 
 	if ( ($pos=strpos($source, '<ul class="categoryActions">'))!==false || ($pos=strpos($source, '<ul class=categoryActions>'))!==false){
-		if ( ($pos2=strpos($source, '</ul>', $pos))!==false 
+		if ( ($pos2=strpos($source, '</ul>', $pos))!==false
 			&& (substr_count($source, '<li>', $pos, $pos2-$pos) > 2) )
 			$source = substr_replace($source, '<a id=albumActionsSwitcher class=pwg-button><span class="pwg-icon pwg-icon-ellipsis"></span></a>{combine_script version=1 id=\'modus.async\' path="themes/`$themeconf.id`/js/modus.async.js" load=\'async\'}', $pos, 0);
@@ -146,29 +146,29 @@
 function modus_css_resolution($params)
 {
-  $base = @$params['base'];
-  $min = @$params['min'];
-  $max = @$params['max'];
-  
-  $rules = array();
-  if (!empty($base))
-    $rules[] = $base;
-  foreach(array('min','max') as $type)
-  {
-    if (!empty($$type))
-      $rules[] = '(-webkit-'.$type.'-device-pixel-ratio:'.$$type.')';
-  }
-  $res = implode(' and ', $rules);
-
-  $rules = array();
-  if (!empty($base))
-    $rules[] = $base;
-  foreach(array('min','max') as $type)
-  {
-    if (!empty($$type))
-      $rules[] = '('.$type.'-resolution:'.round(96*$$type,1).'dpi)';
-  }
-  $res .= ','.implode(' and ', $rules);
-
-  return $res;
+	$base = @$params['base'];
+	$min = @$params['min'];
+	$max = @$params['max'];
+
+	$rules = array();
+	if (!empty($base))
+		$rules[] = $base;
+	foreach(array('min','max') as $type)
+	{
+		if (!empty($$type))
+			$rules[] = '(-webkit-'.$type.'-device-pixel-ratio:'.$$type.')';
+	}
+	$res = implode(' and ', $rules);
+
+	$rules = array();
+	if (!empty($base))
+		$rules[] = $base;
+	foreach(array('min','max') as $type)
+	{
+		if (!empty($$type))
+			$rules[] = '('.$type.'-resolution:'.round(96*$$type,1).'dpi)';
+	}
+	$res .= ','.implode(' and ', $rules);
+
+	return $res;
 }
 
@@ -184,5 +184,5 @@
 	$device = get_device();
 	$container_margin = 5;
-	
+
 	if ('mobile'==$device)
 	{
@@ -224,5 +224,5 @@
 		}
 		while($csize[1]<$row_height-2 && $idx<count($candidates));
-		
+
 		if ($do_pop && $idx<count($candidates))
 		{
@@ -254,6 +254,6 @@
 
 	$my_base_name = basename(dirname(__FILE__));
-  // not async to avoid visible flickering reflow
-  $template->scriptLoader->add('modus.arange', 1, array('jquery'), 'themes/'.$my_base_name."/js/thumb.arrange.min.js", 0);
+	// not async to avoid visible flickering reflow
+	$template->scriptLoader->add('modus.arange', 1, array('jquery'), 'themes/'.$my_base_name."/js/thumb.arrange.min.js", 0);
 	if ($do_pop)
 		$template->scriptLoader->add('modus.pop', 2, array('jquery'), 'themes/'.$my_base_name."/js/thumb.pop.js", 0);
