How would I insert "_thumb" into files that are being dyanmically generated.
For example, I have a site that allows users to upload an image. The script takes the image, optimizes it and saves to file. How would I make it insert the string "_thumb" for the optimized image?
I'm currently saving 1 version of the otpimized file. ch-1268312613-photo.jpg
I want to save the original as the above string, but want to append, "_thumb" like the following string ch-1268312613-photo_thumb.jpg
No need to use regex. This will do it:
$extension_pos = strrpos($filename, '.'); // find position of the last dot, so where the extension starts $thumb = substr($filename, 0, $extension_pos) . '_thumb' . substr($filename, $extension_pos);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With