Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Changing The Filesize Info  (Read 3419 times)

0 Members and 1 Guest are viewing this topic.

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Changing The Filesize Info
« 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
« Last Edit: June 18, 2007, 11:07:34 pm by Nibbler »
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Changing The Filesize Info
« Reply #1 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
Code: [Select]
$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
Code: [Select]
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);
}
Logged
‍I don't answer to PM with support question
Please post your issue to related board

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Changing The Filesize Info
« Reply #2 on: June 18, 2007, 08:56:06 pm »

I replaced

Code: [Select]
$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

Code: [Select]
$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
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Changing The Filesize Info
« Reply #3 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
Logged

Nibbler

  • Guest
Re: Changing The Filesize Info
« Reply #4 on: June 18, 2007, 09:17:56 pm »

Wrong place. The code to change is displayimage.php

Code: [Select]
    $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

Code: [Select]
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']);
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Changing The Filesize Info
« Reply #5 on: June 18, 2007, 10:57:46 pm »

Thank you nibbler, worked a treat ;)
Logged
Pages: [1]   Go Up
 

Page created in 0.016 seconds with 19 queries.