Bugfix for urls with spaces, support for attached images, ability to create thumb

I've been using these changes on my sites for years so I thought I'd commit them on GitHub.