How to make sure the user does not inadvertently dismiss a modal?

I'm working on a page editor where you have the ability to insert images from an external/third-party source. The library of images will be displayed in a modal that sits on top of the page editor. This way, it doesn't disrupt the page editing process if you wish to insert an image to your page.

The issue with the third-party image though is that it might take a while to load. Since we'd have to load the image fully first before we can insert the image into the page, we display a progress bar - this is an ok solution, however, since the progress bar is within the modal, should the user get impatient and dismiss the modal, or if they don't notice the progress bar at all, they might inadvertently dismiss the modal and this breaks the process.