Hi Martin,
I hope you had or still have a relaxing xmas. I already returned to my headdache

Last week I reported my issue at the forum of hostingsociety. The reply was something like "bad coding" and too much resource consuming.
What is meant is the huge number os calls of pic.php like
Code:
<img src="http://deynews.hostingsociety.com/plugins/i18n_gallery/browser/pic.php?g=top-10&p=images%2F%2Fnatur%2Fstart.jpg&w=120&h=80" alt="Meine Top 10" title="Meine Top 10"/>
So I started to read and understand the complex structure.
What is the reason that you call the pic.php that often: safety or comfort?
My first idea was to change the call to pic.php into a real link to the thumbs. So far so good. But then I figured out that I would need to change it at too many location. It's too dangerous that you miss something and any change in the options corrupts everything.
So I thought it might be smarter to reduce the code for/ in pic.php.
I created a second pic.php called new-pic.php. Actually new-pic.php is the original and pic.php the reduced one.
In edit.php and imagebrowser.php I change all links from pic.php into new-pic.php. Reason: it seemed easier to find all calls...
while I write I see I was wrong!
Anyway the reduced code for pic.php looks like
Code:
<?php
$infile = preg_replace('/\.+\//', '', $_GET['p']);
$gallery = @$_GET['g'];
$maxWidth = @$_GET['w'];
$maxHeight = @$_GET['h'];
$crop = @$_GET['c'] && $maxWidth && $maxHeight;
$datadir = substr(dirname(__FILE__), 0, strrpos(dirname(__FILE__), DIRECTORY_SEPARATOR.'plugins')) . '/data/';
$imagedir = $datadir . 'uploads/';
if (!$maxWidth && !$maxHeight) {
header('Content-Type: '.$info['mime']);
readfile($imagedir.$infile);
} else {
$pos = strrpos($infile,'/');
if ($pos === false) $pos = -1;
$outfile = substr($infile, 0, $pos+1) . 'i18npic.' . ($crop ? 'C' : '') . ($maxWidth ? $maxWidth.'x' : '0x') . ($maxHeight ? $maxHeight.'.' : '0.') . substr($infile, $pos+1);
$outfile = substr($outfile, 0, strrpos($outfile,'.')) . '.jpg';
$thumbdir = $datadir . 'thumbs/';
header('Content-Type: image/jpeg');
readfile($thumbdir.$outfile);
}
function error404() {
header('HTTP/1.1 404 Not Found');
header('Content-Type: text/plain');
echo '404 File not found';
exit(0);
}
This I tested at hostingsociety without any positive change.
While I write this I returned to my origin idea to link thumbs with clear direct links and this
works.
Code for helper.php
Code:
function i18n_gallery_thumb_link($gallery, $item=null, $echo=true) {
if (!is_array($item)) $item = @$gallery['items'][-intval($item)-1];
if (!$item) $item = @$gallery['items'][0];
$tw = @$gallery['thumbwidth'];
$th = @$gallery['thumbheight'];
$tc = @$gallery['thumbcrop'] && $tw && $th;
$infile = preg_replace('/\.+\//', '', $item['filename']);
$infile = str_replace("//","/",$infile);
$pos = strrpos($infile,'/');
if ($pos === false) $pos = -1;
$outfile = substr($infile, 0, $pos+1) . 'i18npic.' . ($tc ? 'C' : '') . ($tw ? $tw.'x' : '0x') . ($th ? $th.'.' : '0.') . substr($infile, $pos+1);
$outfile = substr($outfile, 0, strrpos($outfile,'.')) . '.jpg';
$thumbdir = './data/' . 'thumbs/';
$link = $thumbdir.$outfile;
//$link = i18n_gallery_site_link().'plugins/i18n_gallery/browser/pic.php?g='.$gallery['name'].'&p='.urlencode($item['filename']).'&w='.$tw.'&h='.$th.($tc?'&c=1':'');
if ($echo) echo str_replace('&','&',$link); else return $link;
}
What is actually missed now is the creation of thumbs (not for administration)
I manipulated the edit.php (for the other idea as well)
Code:
<td><img src="../plugins/i18n_gallery/browser/new-pic.php?p=<?php echo urlencode($item['filename']); ?>&w=<?php echo $w; ?>&h=<?php echo $h; ?>"/>
<!-- pic.php -> new-pic.php and second call for normal thunmbs-->
<img src="../plugins/i18n_gallery/browser/new-pic.php?p=<?php echo urlencode($item['filename']); ?>&w=<?php echo $tw; ?>&h=<?php echo $th; ?>" height="<?php echo $h*0.25; ?>"/></td>
So I call the (new-)pic.php two times to get the administration and normal thumb when I open a gallery for editing. I guess the separation pic.php and new-pic.pph is not necessary anymore.
Why do I write all this?
With this solution I can't update anymore. So I like to ask if you consider for future a solution as option which treat ressources with more care.
Even with bplaced there's is visible delay of about a second until all thumb in a gallery are visible. And I've just small galleries.
I'm looking forward to here from you.
bydey