Quote:
Originally Posted by TundraSoul
I noticed a very small number of images are saved with some unexpected filenames. For instance: 1.gif?t=1264708348 and so on. What should I do about those, I'm fairly sure they do not work; am I correct?
|
It seems some places will put the question-mark and an id number or such after some images. They probably due this to better track where images are being viewed.
In almost all cases you can erase the ? and everything after it and it will still work as normal.
My "fix" for it therefore was to simply enforce the extension was only 3 characters long.
If you edit the cron file, you'll see I added a line to the function near line 124 of the file.
This is what I'm using and it's working in all the tests I've tried- again the OP please feel free to include this code in the next release if you feel it is useful.
PHP Code:
function iei_get_file_index_name($path, $extension, $oldfilename)
{
// Get only the file name (no directory info)
$oldfilename = basename($oldfilename, $extension);
// Strip out non alpha-numeric characters
$oldfilename = preg_replace('#[^A-Za-z0-9_]#', '', $oldfilename);
// Set max file name length to 40 characters
$oldfilename = substr($oldfilename, 0, 40);
// Force extension to 3 characters only
$extension = substr($extension, 0, 3);
//Increment number if file exists
for($i = 1;; $i++)
{
$filename = "$path/$oldfilename-$i.$extension";
if(!file_exists($filename))
{
return $filename;
}
}
}