While web is very image-heavy medium, browsers aren’t great image viewers. When viewing large images site might try to help with some kind of media viewer (at best), but more often you are starting at part of image that fits in window and scroll back and forth.
Some newer browsers (Firefox at least) can auto-scale images to fit, but this function is missing in Opera and I decided to make JavaScript bookmarklet for such function.
What is needed
Assuming we are looking at image opened by direct URL we only need two things:
- retrieve browser window dimensions;
- resize image accordingly.
Strangely there are many code examples around that show this separately, but no good and simple bookmarklets that combine them at all.
JavaScript
After amount of time I wasted on this, result is laughably tiny:
javascript:(function(){document.images[0].height=window.innerHeight;})();
This code grabs first (zero-ish in computer array speak) image on page and we have only that one when looking at direct URL. Then it assigns to image value of height, taken from browser window object.
Save this as bookmark or drag on browser toolbar (with Shift pressed in case of Opera).
Overall
Feels anticlimactic when something that annoys you for a long time turns out that easy to solve. But if there is one piece of productivity wisdom computers slowly pounded into me – it is getting rid of small annoyances that makes time to tackle more complex and interesting things.
henk #
Rarst #
Ian Andrews #
Rarst #
JHJ #
Rarst #
dave #
Rarst #
dave #
Rarst #
Chad #
Rarst #