I have the same problem with images having spaces in their name. Your solution look definitely the right one, could you please specify the position where you added those code lines? Or attach your file if you prefer. Thank you very much!
More