Fixed a bug and added scaling optimisation

- Fixed a bug when no class is set on the a tags.
- In some cases the new height of the image after rescaling (to fit in
window) is not calculated in the right way. I put this in separate
parameters so jQuery can't mess things up.