All this photo reprocessing brings a danger, of course: I could rename or remove an image to which I have referred on a web page. I already have a 404 document that sends me email if a page on my site refers to a non-existent page, and that has greatly improved things. But you don't get a 404 for a missing image. On the other hand, nearly all my images are generated by a PHP function, so it's (relatively) easy to check whether the image exists or not. The difficulty is mapping the URL to the local path name. I got that done, and I was still having it claim that the images didn't exist.
Debugging PHP is relatively clunky, and in general I put print statements in the code. Gradually I was reduced to using explicit path names:
print <<< EOS
<pre>
'$localimagepath'
'/home/grog/public_html/Photos/20081031/tiny/cj-2.jpeg'
</pre>
...
And I ended up with stuff like:
'/home/grog/public_html/Photos/20081031/tiny/cj-2.jpeg'
It's at times like this that you begin to doubt your sanity. But HTML isn't WYSIWYG. Looking at the HTML source shows a completely different view:
'/home/grog/public_html/Photos/20081031/tiny/cj-2.jpeg'
That makes sense: the image name gets sanitized to HTML entities where the characters could be a problem. The character - by itself isn't a problem, but -- can be interpreted as the end of a comment. All I needed to do was to take the original file name before sanitization, and it worked, and I output code like:
There should be an image http://www.lemis.com/grog/Photos/20080906/tiny/house-e.jpeg here, but it is not present on this server. The webmaster has been alerted. Come back soon.
And how it worked! Error messages started pouring in, for errors that most people, myself included, had never noticed. So I removed the display and just sent the mail messages. I'll reinstate when things become sane again.
