coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: will on June 17, 2007, 10:34:56 PM

Title: Changing The Filesize Info
Post by: will on June 17, 2007, 10:34:56 PM
Is there a way of changing the filesize info so it shows MB if the file is over 1,000 KB

Example: http://cdcoverhideout.com/gallery/displayimage.php?album=lastup&cat=0&pos=0 (You can view without registering)

Any help will be great, I've looked in the english lang file but couldn't see anything.

Thanks ;D
Title: Re: Changing The Filesize Info
Post by: Sami on June 18, 2007, 04:28:48 PM
You should code it under functions.inc.php display_thumbnails function
instead of shifting 10 times to right

$lang_display_thumbnails['filesize'].($row['filesize'] >> 10).$lang_byte_units[1]."\n".


you should shifting 20 times or code you logic , BTW you should check file size before doing this , something like this would help you

if($row['filesize'] << 1000){
$pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".
                                $lang_display_thumbnails['filesize'].($row['filesize'] >> 10).$lang_byte_units[1]."\n".
                                $lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".
                                $lang_display_thumbnails['date_added'].localised_date($row['ctime'], $category_date_fmt);

}else{
$pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".
                                $lang_display_thumbnails['filesize'].($row['filesize'] >> 20).$lang_byte_units[2]."\n".
                                $lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".
                                $lang_display_thumbnails['date_added'].localised_date($row['ctime'], $category_date_fmt);
}
Title: Re: Changing The Filesize Info
Post by: will on June 18, 2007, 08:56:06 PM
I replaced

$pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".
                                $lang_display_thumbnails['filesize'].($row['filesize'] >> 10).$lang_byte_units[1]."\n".
                                $lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".
                                $lang_display_thumbnails['date_added'].localised_date($row['ctime'], $category_date_fmt);


With

$pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".
                                $lang_display_thumbnails['filesize'].($row['filesize'] >> 20).$lang_byte_units[2]."\n".
                                $lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".
                                $lang_display_thumbnails['date_added'].localised_date($row['ctime'], $category_date_fmt);


This still doesn't change anything, and if I add the second part of code under the first part of code I get an error ???

Any help would be great ;D
Title: Re: Changing The Filesize Info
Post by: will on June 18, 2007, 09:01:19 PM
Ignore that last post, everything went ok changing the code but it still doesn't change anything ;D
Title: Re: Changing The Filesize Info
Post by: Nibbler on June 18, 2007, 09:17:56 PM
Wrong place. The code to change is displayimage.php


    $info[$lang_picinfo['File Size']] = ($CURRENT_PIC_DATA['filesize'] > 10240 ? ($CURRENT_PIC_DATA['filesize'] >> 10) . '&nbsp;' . $lang_byte_units[1] : $CURRENT_PIC_DATA['filesize'] . '&nbsp;' . $lang_byte_units[0]);


Try


function bsize($s) {
foreach (array('','K','M','G') as $i => $k) {
if ($s < 1024) break;
$s/=1024;
}
return sprintf("%5.1f %sB",$s,$k);
}

$info[$lang_picinfo['File Size']] = bsize($CURRENT_PIC_DATA['filesize']);
Title: Re: Changing The Filesize Info
Post by: will on June 18, 2007, 10:57:46 PM
Thank you nibbler, worked a treat ;)