Probably a silly mistake that I had to deal with… but if your clients upload image files with spaces in the file name you will end up with broken image links. When returning filenames or paths from the database you want to replace spaces with the HTML entities. But using urlencode() or htmlentities() will not work for this purpose.
Instead use:
rawurlencode()