Modal box container not resizing on small screens

Putting img.width in a variable before calling checkImageDimension will not dimension the bootstrap modal with the right new width.
Fixed by getting img.width after checkImageDimension method