the_post_thumbnail(‘medium’) setting some images width=1 height=1

It’s only a guess, but it’s also most probable cause…

When you upload an image to WP, some metadata is generated and stored in database. This metadata contains such info like name, path and size of the image (to be more precise – paths and sizes of all created images based on uploaded one). And… This metadata is stored as serialized array.

When the metadata is corrupted (so WP is not able to unserialize it), it can cause images with size 1×1 (WP doesn’t know what is the size of given image).

What should you do in such case?

It’s easy to correct this. All you need to do is to regenerate metadata for these images. (There are many plugins which will help you with this – look for “regenerate thumbnails” or “rebuild” thumbnails”).