Skip to content

Comments

[4.1] Display doc icon based on mimetype#36723

Closed
Quy wants to merge 2 commits intojoomla:4.1-devfrom
Quy:mm-icons
Closed

[4.1] Display doc icon based on mimetype#36723
Quy wants to merge 2 commits intojoomla:4.1-devfrom
Quy:mm-icons

Conversation

@Quy
Copy link
Contributor

@Quy Quy commented Jan 17, 2022

Summary of Changes

In Media Manager, documents are displayed as PDF icon. This PR displays the respective icon based on mimetype.

Testing Instructions

Go to Media Manager.
Upload files of types txt, pdf, word, excel, powerpoint.

Thanks @dgrammatiko for the code!

@joomla-cms-bot joomla-cms-bot added NPM Resource Changed This Pull Request can't be tested by Patchtester PR-4.0-dev labels Jan 17, 2022
@Quy Quy marked this pull request as draft January 17, 2022 20:27
@dgrammatiko
Copy link
Contributor

@Quy please add any meaningful mime type needed here from: https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types

@Quy
Copy link
Contributor Author

Quy commented Jan 17, 2022

The i icon confirms that the mimetype is correct, but it is still displaying the generic file icon. ???

@dgrammatiko
Copy link
Contributor

Check that fas fa-file-pdf, etc actually exist, the code in the other PR was a bit of pseudo on terms of the actual font awsome classes

@Quy
Copy link
Contributor Author

Quy commented Jan 17, 2022

fas fa-file-pdf is correct and same as before the PR. It appears to not be detecting the mimetype thus defaulting to fas fa-file

@dgrammatiko
Copy link
Contributor

dgrammatiko commented Jan 17, 2022

Check what the actual mime type is <span v-bind:class="getFileClass" data-mime="{{ item.mime_type}}"/>
Also add break; after each return <-- No don't do that, that's stupid

@Quy
Copy link
Contributor Author

Quy commented Jan 17, 2022

<span class="fas fa-file" data-mime="{{item.mime_type}}"></span>

@dgrammatiko
Copy link
Contributor

dgrammatiko commented Jan 17, 2022

Add it to line 16

    <div class="media-browser-item-info">
      {{ item.name }} {{ item.filetype }} {{item.mime_type}}
    </div>

@Quy
Copy link
Contributor Author

Quy commented Jan 17, 2022

{{ item.filetype }} = empty
{{ item.mime_type }} = application/pdf

@dgrammatiko
Copy link
Contributor

Change getFileClass: (item) => { to getFileClass() {

@Quy
Copy link
Contributor Author

Quy commented Jan 18, 2022

ReferenceError: item is not defined

  computed: {
    /* Get the hashed URL */
    getFileClass() {
      switch (item.mime_type) {
        case 'application/pdf':
          return 'fas fa-file-pdf';
        case 'application/msword':
        case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
          return 'fas fa-file-word';
        case 'application/vnd.ms-excel':
        case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
          return 'fas fa-file-excel';
        case 'application/vnd.ms-powerpoint':
        case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
          return 'fas fa-file-powerpoint';
        default:
          return 'fas fa-file';
      }
    },
  },

@dgrammatiko
Copy link
Contributor

this.item then

@Quy
Copy link
Contributor Author

Quy commented Jan 18, 2022

Hallelujah! Thank you!!

@Quy Quy changed the base branch from 4.0-dev to 4.1-dev January 20, 2022 03:21
@Quy Quy changed the title [4.0] Display doc icon based on mimetype [4.1] Display doc icon based on mimetype Jan 20, 2022
@Quy Quy removed the PR-4.0-dev label Jan 20, 2022
@Quy
Copy link
Contributor Author

Quy commented Feb 3, 2022

Will redo later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NPM Resource Changed This Pull Request can't be tested by Patchtester

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants