Wrong url for the images while using same database for two WordPress installations

That little hack just “fixes” the URL when you call the home or siteurl options, image paths are not affected by that.

Depending on where you want to show images, you could apply a filter to the_content, search for your URL and add your subfolder to it. Then you could show images in your post content.

I don´t know if there is a better, “wider” filter to capture all output, but this might get you going…