Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How do I show a file-extension related icon on attachments?

I'd like to show the relevant icon associated with attachments (e.g. .doc, .docx, .xls, .xlsx) rather than the generic one

Any ideas?

Best Answer

  • jackmaessenjackmaessen ✭✭✭
    Answer ✓

    in class.mediamodel.php of Uploader plugin there is this piece of code about line 190

      public static function ThumbnailUrl(&$Media) {
          if (GetValue('ThumbPath', $Media))
             return Gdn_Upload::Url(ltrim(GetValue('ThumbPath', $Media), '/'));
    
          $Width = GetValue('ImageWidth', $Media);
          $Height = GetValue('ImageHeight', $Media);
    
          if (!$Width || !$Height) {
             if ($Height = self::ThumbnailHeight())
                SetValue('ThumbHeight', $Media, $Height);
             return '/plugins/FileUpload/images/file.png';
          }
    

    You can see the file.png is default loaded. So you have to make a kind of switch with cases to load different .png files

Answers

  • What are you using for attachments?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • which one do you mean, the big one or the little one?

  • rbrahmsonrbrahmson ✭✭✭

    The big one...

  • rbrahmsonrbrahmson ✭✭✭

    And I'm using the Uploader plugin for attachments

  • jackmaessenjackmaessen ✭✭✭
    Answer ✓

    in class.mediamodel.php of Uploader plugin there is this piece of code about line 190

      public static function ThumbnailUrl(&$Media) {
          if (GetValue('ThumbPath', $Media))
             return Gdn_Upload::Url(ltrim(GetValue('ThumbPath', $Media), '/'));
    
          $Width = GetValue('ImageWidth', $Media);
          $Height = GetValue('ImageHeight', $Media);
    
          if (!$Width || !$Height) {
             if ($Height = self::ThumbnailHeight())
                SetValue('ThumbHeight', $Media, $Height);
             return '/plugins/FileUpload/images/file.png';
          }
    

    You can see the file.png is default loaded. So you have to make a kind of switch with cases to load different .png files

  • rbrahmsonrbrahmson ✭✭✭

    Thanks @jackmaessen - I wrongly assumed that the icon is determined by Vanilla regardless of what is used to upload the attachment... Your quick response redirected me to the right spot. I appreciate your help!

Sign In or Register to comment.