We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6726
    • 7,075 Posts
    OK Doze, it seems to work when I add an image it gets the filesize but I must have chosen the wrong field type in phpMyAdmin, I have an INT for it but I suspect as sizereadable "humanize" the filesize it’s not anything like 12468996 but 1.2 for instance.

    I have a 1.2 MB file which is added with the value "1".

    ?

      .: COO - Commerce Guys - Community Driven Innovation :.


      MODx est l'outil id
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It should be stored as an int, then the code to extract it and prepare it for display should "pretty-print" it. It’s possible you might want to do some kind of mathematical calculations with it, which you won’t be able to do if you store it already pre-formatted.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 7923
        • 4,213 Posts
        The size_readable function that you posted to this thread returns the size as "human readable" string, so the DB field should be varchar. You can of course change it so that the DB field is integer and the size is stored there just using the filesize php function. Then do a PHx custom modifier that changes it to human readable form via size_readable and use it in the maxigallery template.


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 6726
          • 7,075 Posts
          OK Doze thanks a lot I’ll go ahead and change that !
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l'outil id