Persistent picture size.
Status: Beta
Brought to you by:
pappkamerad
When I resize an image to 800x600 or whatever, I'd
prefer when I click next or previous that the next or
previous image be the same size, so I don't have to
keep clicking 800x600 each image (or eventually get
tired of doing it and settle with the smaller ones!)
Logged In: YES
user_id=1276995
Try doing this in WRAPPER.PHP (see notes for changes):
foreach ($cfg['view_sizes'] as $view_size => $view_width) {
if (((isset($_GET['size']) && $_GET['size'] ==
$view_size) || (!isset($_GET['size']) && $view_size ==
$cfg['default_view'])) && $_GET['orig'] != 1) {
$view_size_links[$i]['href'] = '';
$view_size_links[$i]['name'] =
utf8_encode($cfg['view_sizes'][$view_size]);
$pn_size = $i; // NEW LINE
}
else {
$view_size_links[$i]['href'] =
utf8_encode($web_pAG_path_rel . $web_current_path . $file ).
'?size=' . $view_size . '&offset=' . $_GET['offset'];
$view_size_links[$i]['name'] =
utf8_encode($cfg['view_sizes'][$view_size]);
}
$i++;
}
// generate original link if allowed
$view_original_link = array();
if ($cfg['allow_original_view']) {
if ($_GET['orig'] == 1) {
$view_original_link['href'] = '';
$view_original_link['name'] = 'Original';
$view_original_link['allowed'] = true;
$decide = 'orig'; // NEW LINE
}
else {
$view_original_link['href'] =
utf8_encode($web_pAG_path_rel . $web_current_path . $file .
'?orig=1') . '&offset=' . $_GET['offset'];
$view_original_link['name'] = 'Original';
$view_original_link['allowed'] = true;
}
}
else {
$view_original_link['href'] = '';
$view_original_link['name'] = 'Original';
$view_original_link['allowed'] = false;
}
$prev_next = ($decide == 'orig' ? '?orig=1' :
'?size='.$pn_size ); // NEW LINE
// get next/previous pictures filenames
//prev
if ($current_picture_file_position == 0) {
$prev_picture['href'] = '';
$prev_picture['img'] = '';
$prev_picture['name'] = '';
$prev_picture_file = '';
}
else {
$prev_picture_file =
$current_picture_files[$current_picture_file_position -
1]['name'];
$prev_name = substr($prev_picture_file, 0,
strrpos($prev_picture_file, '.'));
$current_tmp_path = $cfg['tmp_path'] .
$cfg['tmp_pAG_path'] . $web_pAG_path_abs . $web_current_path;
if (!file_exists($current_tmp_path)) {
createTmpDirs($cfg['tmp_path'], $cfg['tmp_pAG_path']
. $web_pAG_path_abs . $web_current_path);
}
$tmpfilename = 't' . $cfg['next_previous_size'] . '_' .
$prev_name . '.jpg';
if (!file_exists($current_tmp_path . $tmpfilename)) {
$image = new Image_Toolbox($filesystem_current_path .
$prev_picture_file);
$image->newOutputSize($cfg['next_previous_size'], 0,
false, true);
$image->save($current_tmp_path . $tmpfilename, 'jpg',
$cfg['jpeg_quality']);
unset($image);
}
list($prev_picture['resized_width'],
$prev_picture['resized_height']) =
getimagesize($current_tmp_path . $tmpfilename);
if (($current_picture_file_position) == $_GET['offset']) {
$prev_offset = $_GET['offset'] - $cfg['pics_per_page'];
}
else {
$prev_offset = $_GET['offset'];
}
$prev_picture['href'] = utf8_encode($web_pAG_path_rel .
$web_current_path . $prev_picture_file ). $prev_next .
'&offset=' . $_GET['offset']; // CHANGED LINE
$prev_picture['img'] = utf8_encode($web_pAG_path_rel .
'__phpAutoGallery__picLoaderTmp/' . $web_pAG_path_abs .
$web_current_path . $tmpfilename);
$prev_picture['name'] =
utf8_encode(samba2workaround($prev_picture_file));
$prev_picture['size'] =
humansize($current_picture_files[$current_picture_file_position
- 1]['size']);
$prev_picture['date'] = strftime($cfg['timeformat'],
$current_picture_files[$current_picture_file_position -
1]['timestamp']);
}
//next
if ($current_picture_files_count ==
($current_picture_file_position + 1)) {
$next_picture['href'] = '';
$next_picture['img'] = '';
$next_picture['name'] = '';
$next_picture_file = '';
}
else {
$next_picture_file =
$current_picture_files[$current_picture_file_position +
1]['name'];
$next_name = substr($next_picture_file, 0,
strrpos($next_picture_file, '.'));
$current_tmp_path = $cfg['tmp_path'] .
$cfg['tmp_pAG_path'] . $web_pAG_path_abs . $web_current_path;
if (!file_exists($current_tmp_path)) {
createTmpDirs($cfg['tmp_path'], $cfg['tmp_pAG_path']
. $web_pAG_path_abs . $web_current_path);
}
$tmpfilename = 't' . $cfg['next_previous_size'] . '_' .
$next_name . '.jpg';
if (!file_exists($current_tmp_path . $tmpfilename)) {
$image = new Image_Toolbox($filesystem_current_path .
$next_picture_file);
$image->newOutputSize($cfg['next_previous_size'], 0,
false, true);
$image->save($current_tmp_path . $tmpfilename, 'jpg',
$cfg['jpeg_quality']);
unset($image);
}
list($next_picture['resized_width'],
$next_picture['resized_height']) =
getimagesize($current_tmp_path . $tmpfilename);
if (($current_picture_file_position + 1) ==
($_GET['offset'] + $cfg['pics_per_page'])) {
$next_offset = $_GET['offset'] + $cfg['pics_per_page'];
}
else {
$next_offset = $_GET['offset'];
}
$next_picture['href'] = utf8_encode($web_pAG_path_rel .
$web_current_path . $next_picture_file ). $prev_next .
'&offset=' . $_GET['offset']; // CHANGED LINE