Zum Hauptinhalt gehen

Howto display the filesize next to a download link

Kommentare

2 Kommentare

  • Zendesk API User
    Author: hoebbel - 6/28/2010 8:35

    Of course this will work only with media-store elements, not with sitestore pagerefs!

    [Just a reminder, since within the example  "ref(#link.sitestoreref)" is used :smileywink:

    0
  • Zendesk API User
    Author: sglock - 7/14/2010 16:24

    Hi,

    here's my two cents from a usability point of view:

    I recommend displaying downloads below 1 MB without fractional digits since the exact size seems rather irrelevant in most cases. What's more important for the user is the type of document that's going to be downloaded. You may also want to use non-breaking spaces to prevent "orphans" in your layout.

    The following example will print out e.g. "Manual [pdf, 1,2 MB]" or "Poster [jpg, 723 kB]".

    $CMS_IF(ref(#link.mediaref).size > 999999)$
         $CMS_SET(downloadsize, ref(#link.mediaref).size.humanReadable("*","#0.0 {U}"))$
    $CMS_ELSE$
         $CMS_SET(downloadsize, ref(#link.mediaref).size.humanReadable("*","#0 {U}"))$
    $CMS_END_IF$

     
    $CMS_VALUE(#link.text + "\&nbsp[" + ref(#link.mediaref).extension + ",\&nbsp" + downloadsize.replaceAll(" ","\&nbsp") + "]")$

    (Sorry for the backslash before the "&nbsp" - it's only there to make the non-breaking space visible in this comment-section. (Semicolons are missing, too.) There's probably a better way to do that.)

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.