My question is quick and simple.
I am creating a gallery and I am fetching my full-size images and my thumbnails from a directory using glob.
I have a variable for the path to my thumbnail images : images/photo-strip/thumb/*.jpg
I am reducing the path images/photo-strip/thumb/*.jpg
to *.jpg
using basename()
and I save that to $filename
Then I re-build the path to the full size image like this: $pathToFull = 'images/photo-strip/' . $filename;
My files inside the thumb folder are named like so: th_*.jpg
and the full size images are *.jpg
(exactly matching but without the th).
I then have an echo that puts the HTML, with thumbnail path in an <img>
tag and fullsize path to an <a>
tag.
Problem is the path to my full-size images is wrong because of the th_ in the filenames of the images.
Is there a way to trim the th_
from $filename
and save it to something like $full_filename
so I can correct the filename for the full-size images?
I could easily rename the thumbnail images to exclude th_ and this would solve my problem but I would prefer to leave the file names as is.
EDIT:
I am using BCMCFC's method as it get's rid of two lines of code that I don't neccessarily have to have.
Thanks for the speedy answers!