Wednesday, 4 May 2011

Fix for my php probs!

After a few weeks of frustration, I've finally fixed up my thumbnail probs on my alternativecontext.com portfolio site - the fix was to do with the default timezone setting.

Thanks to Vamonos Software for the post that lead me to a solution for my prob (tho I did it slightly differently...)

Issue: Images were being generated in the timthumb cache, but not displaying on my site. Was convinced it was to do with caching/headers, I looked in my sites apache error log, and lo and behold I had been getting these errors:

[Sat Apr 30 09:52:05 2011] [error] [client 66.249.72.45] PHP Warning:  strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/London' for 'BST/1.0/DST' instead in /var/www/alternativecontext.com/htdocs_3.0/wp-content/themes/ePhoto/timthumb.php on line 526, referer: http://alternativecontext.com/2010/04/30/naked-vets-minature/

The fix was pretty simple - could either set the default.timezone in php.ini, or for me (better as I'm on a server with mutiple sites), add the following to the timthumb.php script in my wordpress theme, as the first line of function show_cache_file($mime_type):

date_default_timezone_set('Europe/London');

Reset my wordpress page cache, and HURRAY, all is fixed!