localhost on iPhone not loading images

Unfortunately, when changing the URL of your site with WordPress, you also need to do a pretty big find/replace job in the database: this is because any links or images (and probably a number of other things too) added to posts have absolute (http://localhost:8888/wp-content/uploads/etc.) rather than relative links (/wp-content/uploads/etc.).

Thus, all your images embedded in your posts are still attempting to load from localhost, which doesn’t exist apart from on your local computer.

There’s a quick and dirty way to fix this: export your database into an SQL file, make a copy, open it in a text editor, and do a find/replace on http://localhost:8888 replacing it with http://192.168.0.19:8888. Then import it again over your existing database (make sure you still have that exported copy of your existing database first!)

This option is quick, and certainly works in most cases for a quick ‘check’ that things are in order, but it’s very likely to kill some of your data, so you’ll need to re-import that database export copy once you’re done so you can get everything back.

If you’re wanting to do this for real – which you certainly will need to when you deploy your site live – you’ll need to do a serialised search/replace on the database. WordPress stores some of its settings (including widget content, for instance) in serialised strings, which basically means if you manually change the content in these strings and it’s not exactly the same length as it was before, the content will be lost.

This is a great script that solves that problem and works in most cases. It’s not too difficult to set up either. Another option is wp-cli which is easier if you’re going to be doing this a lot, but is more work to set up and learn in the first instance.