XF 2.1 How to automatically resize images in posts, but on mobile only

I’m trying to figure out some code I can use to automatically resize images to a specific width, but I’d like to do this for mobile browsing only. Does anybody have any thoughts on how this may be achieved?

Thank you in advance!
 
I’m not worried about changing the files themselves, just their display settings.

For instance, I’d like to have images display no wider than say 500px when browsing on mobile devices only.
 
Top Bottom