fix setting size to 0px

I have seen some cases where this cause the size to be set to 0.
It seemed that the image has not been fully loaded yet.
Surrounding it with $(document).ready fixed it for me.