Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1, 2.2
    • Fix Version/s: DEV backlog
    • Component/s: Files API
    • Labels:
    • Testing Instructions:
      Hide

      Unit test is included. For a simple custom test, open any page with WYSIWYG editor and click on 'Add image' or 'Add media', in the first case only image file should be listed in the repositories, in the second only audio and video ones.

      Show
      Unit test is included. For a simple custom test, open any page with WYSIWYG editor and click on 'Add image' or 'Add media', in the first case only image file should be listed in the repositories, in the second only audio and video ones.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:
      wip-MDL-32247-files23

      Description

      I have discovered recently that there are two separate mimetype-related features in Moodle. One is several mimetype functions that use get_mimetypes_array() as the source, another one is filetype_parser class that is using file_types.mm mindmap file as a data source.

      In my opinion, having two data sources may cause inconsistencies and dissimilarities in mime data we work with, thus I suggest to remove one of them (likely the mindmap one) and design a function for deriving the list of file extensions from existing mimetypes array (i.e. replicate filetype_parser functionality and refactor few bits where it is used).

      Andrew provided a quick proof of concept for this:

      function get_mimetype_matches($match) {
          if (!is_array($match)) {
              $match = array($match);
          }    
          $mimetypes = get_mimetypes_array();
          $results = array();
          foreach($mimetypes as $key => $data) {
              if (in_array($data['type'], $match)) {
                  $results[$key] = $data;
              }    
          }    
          return $results;
      }

      Would be good to know people's opinion about this change.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: