Howto: Attachment icons

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kaitlyn2004
    Senior Member
    • Jul 2006
    • 137

    Howto: Attachment icons

    When you have an attachments for an issue, if it is an image it can display a thumbnail - otherwise it is just blank. This instead displays an icon for the filetype:

    Open pt_attachmentbit and find:
    HTML Code:
             <if condition="$attachment['thumbnail_filesize']">
                <a href="projectattachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]" target="_blank"><img src="projectattachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;thumb=1" alt="" border="0" /></a>
            <else />
                &nbsp;
            </if>
    Replace with:
    HTML Code:
             <if condition="$attachment['thumbnail_filesize']">
                <a href="projectattachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]" target="_blank"><img src="projectattachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;thumb=1" alt="" border="0" /></a>
            <else />
                <img src="images/attach/$attachment[extension].gif" width="16" height="16" alt="" />
            </if>
    If you don't want to display the image, you can always display the icon... replace with this instead:
    HTML Code:
    <img src="images/attach/$attachment[extension]_32.gif" width="32" height="32" alt="" />
    Finally, create a plugin for "project_issue_attachmentbit" and use this code:
    PHP Code:
    $attachment['extension'] = substr($attachment['filename'], strrpos($attachment['filename'], '.')+1); 
    AskItOnline.com - Need answers? Ask it online.
    Create powerful online surveys with ease in minutes!
    Sign up for your FREE account today!
  • DelphiVillage
    Senior Member
    • Apr 2002
    • 1051
    • 4.1.x

    #2
    that sounds like a bug ? nice catch through

    Comment

    • TECK
      Senior Member
      • Dec 2001
      • 1508
      • 3.8.x

      #3
      It is not a bug. Kaitlyn2004, you should never hardcode the /images/attach folder.
      Use the built-in vBulletin variables, instead:
      PHP Code:
      $stylevar[imgdir_attach]

      // easier way to grab the extension (and avoid possible file.inc.php formats)
      $extension array_reverse(explode(chr(46), $attachment['filename']));
      $attachment['extension'] = $extension[0]; 
      IMO, I think the first post should be at vBulletin.org site instead of here.
      Floren Munteanu
      Axivo Inc.
      Axivo Searchlight - Turbocharge your web site

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...