diff --git a/4chan_x.coffee b/4chan_x.coffee index 5a83a5869..a787a4e00 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -429,14 +429,17 @@ imageResize = (cw, ch, imageType, image) -> switch imageType when 'full' - image.removeAttribute 'width' + image.removeAttribute 'style' return when 'fit width' - ratio = cw/iw + if iw > cw + image.style.width = '100%' + image.style.margin = '0px' when 'fit screen' ratio = Math.min cw/iw, ch/ih - if ratio < 1 - image.width = Math.floor ratio * iw + if ratio < 1 + image.style.width = Math.floor ratio * iw + image.style.margin = '0px' imageThumb = (thumb) -> thumb.className = '' diff --git a/4chan_x.js b/4chan_x.js index 265add903..0657e1f1e 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -615,16 +615,19 @@ ih = Number(ih); switch (imageType) { case 'full': - image.removeAttribute('width'); + image.removeAttribute('style'); return; case 'fit width': - ratio = cw / iw; - break; + if (iw > cw) { + image.style.width = '100%'; + return image.style.margin = '0px'; + } case 'fit screen': ratio = Math.min(cw / iw, ch / ih); - } - if (ratio < 1) { - return image.width = Math.floor(ratio * iw); + if (ratio < 1) { + image.style.width = Math.floor(ratio * iw); + return image.style.margin = '0px'; + } } }; imageThumb = function(thumb) {