Help with a php query
Ok so i found this php script online it seems to look like it would work for my purposes but I do not want to type it out for every single image I load
$img = "../pics/thumbs/{$row['part_numbers']}.jpg";
$image_width = getimagesize($img);
if(!getimagesize($img)) // if image does not exist, replace with secondary
{
echo "<td width=\"15%\"><img src=\"slotcars/logos/fly_logo.jpg\"></img>";
}
else{ // everything is ok, load original image
echo "<td width=\"15%\"><img src=\"../pics/thumbs/{$row['part_numbers']}.jpg\"></img>";
}
Here is what I want. The site i use allows images to be uploaded from an popular online tech broadcast. right now it saves all these images localy on the server what I want to do ultimately is have the images saved on an Amazon S3 cloud bucket then when the image loads on the page it polls the S3 buckett for the picture if it does not exist then it pulls it from the local server.
The upload part i am going to work on later right now what i want is a way to check if images exist on the S3bucket using a variation of the script above and if it is not there pull it from the local server. I have the bucket mapped to a subdomain which i will not put here as i do not want to violate the TOS for the forum.
However an example would be image.mysite.com being the subdomain mapped to a S3 buckett and screencaps/ being the folder of the local store
If the above script works then how do i make this a function and store it in an external file so i can just call the function when needed?