Thumbnail size changes after clicking on the image link

So I am running into a strange issue

In the cross-selling product sliders, all the thumbnails look fine. (Previously the thumbnails were spilling over onto the product information, and I corrected this by increasing the height of the image-container within the product card, although this current issue was occurring even before my fix)

The issue appears when an item in the cross-selling is clicked, and you are taken to that product’s product detail page. If you return again to the previous page, the thumbnail of that product in the cross-selling product slider has shrunk. Multiple thumbnails can be shrunk at once if their image links are clicked and returned to the previous page in relatively quick succession.

All the thumbnails are displaying the version of the image (400x400), but the shrunk thumbnails are displaying the largest version of the image (1920x1920), and must be compressed to fit inside the card.

I am not sure how sw_thumbnail determines which size of the thumbnail is being displayed, and so I am not sure how to even begin fixing this issue. Does anyone have any ideas?