Bana bir komut bir fotoğrafın küçük resim yolunu almak yardımcı olan aşağıdaki php kodu var
It will take a supplied value like this from a mysql DB '2/34/12/thepicture.jpg' It will then turn it into this '2/34/12/thepicture_thumb1.jpg'
Eminim bunu yapmanın daha iyi bir performans yolu var ve ben her türlü yardıma açığım lütfen
Ayrıca 50 kullanıcının bir sayfada bu 50 farklı fotoğrafları almak için 50 kez aday olacağını
// the photo has it is pulled from the DB, it has the folders and filename as 1
$photo_url = '2/34/12/thepicture_thumb1.jpg';
//build the full photo filepath
$file = $site_path. 'images/userphoto/' . $photo_url;
// make sure file name is not empty and the file exist
if ($photo_url != '' && file_exists($file)) {
//get file info
$fil_ext1 = pathinfo($file);
$fil_ext = $fil_ext1['extension'];
$fil_explode = '.' . $fil_ext;
$arr = explode($fil_explode, $photo_url);
// add "_thumb" or else "_thumb1" inbetween
// the file name and the file extension 2/45/12/photo.jpg becomes 2/45/12/photo_thumb1.jpg
$pic1 = $arr[0] . "_thumb" . $fil_explode;
//make sure the thumbnail image exist
if (file_exists("images/userphoto/" . $pic1)) {
//retunr the thumbnail image url
$img_name = $pic1;
}
}
Ben merak ediyorum 1 şey uzantısı her zaman 3 basamaklı olacak çünkü, dosya uzantısı almak için () pathinfo kullanır nasıl, olur bu değer daha iyi performans almanın diğer yöntemler?