This seems trivial but after all the research and coding I can\'t get it to work. Conditions are:
Update 2018-04-11
Here's a Javascript-less, CSS-only solution. The image will dynamically be centered and resized to fit the window.
The [other, old] solution, using JQuery, sets the height of the image container (body
in the example below) so that the max-height
property on the image works as expected. The image will also automatically resize when the client window is resized.
Note: User gutierrezalex packaged a very similar solution as a JQuery plugin on this page.