I store the original image path(included file name) in db when upload an image.
For example:
img/uploaded/photo.jpg
Then I generate its thumbnail and store in below directory NOT in db.
/img/uploaded/thumbs/photo_thumb.jpg
And I have following function but no idea how to get the thumb which belong to the url in db.
//ie: $file is img/uploaded/photo.jpg
public function get_thumb($file)
{
//get the path without filename
$get_path = dirname($file) . "/thumbs/";
//result img/uploaded/thumbs/ (how can i get the photo_thumb.jpg) here?
return $get_path;
}
Edit
basename($file) to get filename from path but how to add _thumb.jpg?
Don’t have much experience with PHP but using this as starting point, I get:
As I said, not much experience with PHP, but this should do it…
A more easy way to do this, could be:
/in$filethumbs/after it or replace it with/thumbs/.in the edited $file_thumbafter itYou can find the postitions of
/and.with thestrrchrfunction (documented here).