diff --git a/4chan_x.js b/4chan_x.js index ded18016e..c8f463ed9 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1936,8 +1936,9 @@ case 'full': return img.removeAttribute('style'); case 'fit width': - if (iw > cw) { - img.style.width = '100%'; + ratio = cw / iw; + if (ratio < 1) { + img.style.width = Math.floor(ratio * iw); return img.style.margin = '0px'; } break; diff --git a/script.coffee b/script.coffee index b85ed1057..f931b77e2 100644 --- a/script.coffee +++ b/script.coffee @@ -1472,13 +1472,14 @@ imgExpand = when 'full' img.removeAttribute 'style' when 'fit width' - if iw > cw - img.style.width = '100%' + ratio = cw/iw + if ratio < 1 + # y'know, this width is constant between resizes + img.style.width = Math.floor ratio * iw img.style.margin = '0px' when 'fit screen' ratio = Math.min cw/iw, ch/ih if ratio < 1 - #XXX maybe needs + 'px' ? img.style.width = Math.floor ratio * iw img.style.margin = '0px'