Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-47326

Moodle tries to generate thumbnails for files it can't handle, then returns harcoded thumbnail icon

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Deferred
    • Icon: Minor Minor
    • None
    • 2.7.2, 3.1, 3.3.2, 3.3.3, 3.4
    • Filepicker, Files API, Themes
    • MOODLE_27_STABLE, MOODLE_31_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE

      If you upload a .bmp file into Moodle (and I'm guessing the same applies to any image filetype that the GD graphics library cannot convert from) then when viewed in the filemanager it is recognized as an image file and a thumbnail is attempted to be generated.

      When it fails, it returns instead a hardcoded fallback icon which cannot be overriden by themes, and doesn't take advantage of Moodle's image fallback system to provide SVG, then PNG when not supported.

      The hardcoding is on line 2399 of lib/filelib.php:

      if (!$preview_file) {
      // unable to create a preview of the file, send its default mime icon instead
      ...
      $fileicon = file_file_icon($stored_file, $size);
      send_file($CFG->dirroot.'/pix/'.$fileicon.'.png', basename($fileicon).'.png');

      The ideal solution would be to recognize that only certain image filetypes can have previews generated for them and to not even try for other image filetypes but instead let the generic icon already provided by the theme remain in use.

      Currently if you override the .bmp icon in a theme, when shown in the filepicker it will flash up for a short period of time before being replaced by a "thumbnail" which is actually the default icon.

        1. svg.PNG
          28 kB
          Dirk Meyer

            Unassigned Unassigned
            bawjaws David Scotson
            Votes:
            5 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.