Saturday, August 20, 2005

Making The Thumbnail Feature (PHP Safemode friendly)

I've noticed that users sending their profile pictures weren't getting their thumbnail pictures updated. After a little investigation, the fault lays within the UID / GID owner of the file. (i'd suspect it's the new security policy of the server). Thus, newly created thumbnail are rendered as "chown" by the apache process rather than the mychub server.

Thus, a quick and dirty solution is to wipe the existing thumbnail file and re-creating a new one based on the file upload. Below is a snippet of the changed code:-

------------- START OF CODE ------------------------

if (file_exists($this->dest)) { $old_size = getimagesize($this->dest); if ($old_size[0] == $this->CalcWidth()){ unlink($this->dest); $exist = false;
}else{ $exist=false;

------------ END OF CODE -----------------------------

~ an optimised version of the code will be released later. Probably freeing the unused file checking procedure.

No comments: