This PHP code below will take an image and add the word _thumb in between the filename and file extension
This file is called up to 50 times on some pages to show user photo, please not I only linked to a full path image on another server for this example, the file path is usually pulled from a Mysql DB that stores the path to a users photo
I am currently restructuring a lot of things on my site though and I am wanting to know if this is a bad way?
I store a thumbnail image like this:
filename_thumb.jpg
So on a page to view a thumbnail, I only have the path to the full size image and I must add the _thumb part into the filename before displaying the image to screen.
Would it be better performance to do something like
t_filename.jpg
The data that come from the database is like this:
user/photos/1/23/45/34/filename.jpg
So if I changed where I add the thumb part to the fron of the name would it still have to run all the code below to get a result? Please notice how the path I get from the DB is not JUST a filename it has the folder structure saved into it as well and the folders are always different.
<?php
$file = 'http://file-managers.net/skins/blue/images/actions/view_tree.png';
$fil_ext1 = pathinfo($file);
$fil_ext = $fil_ext1['extension'];
$fil_explode = '.' . $fil_ext;
$arr = explode($fil_explode, '/skins/blue/images/actions/view_tree.png');
$pic1 = $arr[0] . "_thumb" . $fil_explode;
// will show;
// /skins/blue/images/actions/view_tree_thumb1.png
echo $pic1;
?>