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

Drag and Drop Image feature does not support image files ending with UPPERCASE file extensions

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.4, 2.4.1, 2.5
    • Fix Version/s: 2.3.5, 2.4.2
    • Component/s: JavaScript
    • Labels:
    • Testing Instructions:
      Hide

      master branch only:

      1. Make sure the label settigns (site admin > plugins > activities > label) allow images to be dragged and dropped into a course page
      2. Turn editing on in a course
      3. Drag and drop an image file with a lower-case extension (e.g. 'cat.jpg')
        • Check the option to 'add image to course page' is offered (along with 'create file resource')
      4. Drag and drop an image file with an upper-case extension (e.g. 'cat.JPG')
        • Check the option to 'add image to course page' is offered (along with 'create file resource')

      all branches (2.3/2.4/master):

      1. Turn editing on in a course
      2. Drag and drop a zip file with lower-case extension (e.g. 'files.zip')
        • Check the options to 'unzip the files and create a folder' and 'create a SCORM' are offered (along with 'create file resource')
      3. Drag and drop a zip file with upper-case extension (e.g. 'files.ZIP')
        • Check the options to 'unzip the files and create a folder' and 'create a SCORM' are offered (along with 'create file resource')

      As always with drag and drop, this only applies to supported browsers (Firefox, Chrome, IE10, Safari?)

      Show
      master branch only: Make sure the label settigns (site admin > plugins > activities > label) allow images to be dragged and dropped into a course page Turn editing on in a course Drag and drop an image file with a lower-case extension (e.g. 'cat.jpg') Check the option to 'add image to course page' is offered (along with 'create file resource') Drag and drop an image file with an upper-case extension (e.g. 'cat.JPG') Check the option to 'add image to course page' is offered (along with 'create file resource') all branches (2.3/2.4/master): Turn editing on in a course Drag and drop a zip file with lower-case extension (e.g. 'files.zip') Check the options to 'unzip the files and create a folder' and 'create a SCORM' are offered (along with 'create file resource') Drag and drop a zip file with upper-case extension (e.g. 'files.ZIP') Check the options to 'unzip the files and create a folder' and 'create a SCORM' are offered (along with 'create file resource') As always with drag and drop, this only applies to supported browsers (Firefox, Chrome, IE10, Safari?)
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull Master Branch:
      MDL-38033_dnd_uppercase_extn

      Description

      The Drag and Drop Image code by Davo Smith (as of 14th February 2013), for image embed purposes, only recognizes file extensions that are in lowercase. E.g., *.png and *.jpg embed correctly when dragged to the course page. However, image files that end with the file extensions *.PNG and *.JPG will end up as image file links instead of being embedded inside the course page.

        Gliffy Diagrams

          Activity

          Hide
          dobedobedoh Andrew Nicols added a comment -

          I think you know this one's coming...

          Show
          dobedobedoh Andrew Nicols added a comment - I think you know this one's coming...
          Hide
          frankiekam Frankie Kam added a comment -

          HI Andrew. I think it's a trivial code portion that needs amending. However, I was unable to find it. I think Davo's onto it.

          Show
          frankiekam Frankie Kam added a comment - HI Andrew. I think it's a trivial code portion that needs amending. However, I was unable to find it. I think Davo's onto it.
          Hide
          dobedobedoh Andrew Nicols added a comment -

          Yeah - I saw the forum post. I've assigned it to Davo (hence the previous comment).

          Thanks for reporting,

          Andrew

          Show
          dobedobedoh Andrew Nicols added a comment - Yeah - I saw the forum post. I've assigned it to Davo (hence the previous comment). Thanks for reporting, Andrew
          Hide
          davosmith Davo Smith added a comment -

          As I thought - I just need to add '.toLowerCase()' to the end of one line in dndupload.js function handle_file.

          I'll put together a proper patch and submit for integration.

          Thanks for finding this Frankie!

          Show
          davosmith Davo Smith added a comment - As I thought - I just need to add '.toLowerCase()' to the end of one line in dndupload.js function handle_file. I'll put together a proper patch and submit for integration. Thanks for finding this Frankie!
          Hide
          frankiekam Frankie Kam added a comment -

          You're most welcome.

          Show
          frankiekam Frankie Kam added a comment - You're most welcome.
          Hide
          frankiekam Frankie Kam added a comment - - edited

          BTW, taking a cue from your discovery of how to cure the bug, I added this line of code:
          extension = extension.toLowerCase();
          inside the handle_file function of the file named moodle/course/dndupload.js (in my Moodle Production site)

          handle_file: function(file, section, sectionnumber) {
          var handlers = new Array();
          var filehandlers = this.handlers.filehandlers;
          var extension = '';
          var dotpos = file.name.lastIndexOf('.');
          if (dotpos != -1)

          { extension = file.name.substr(dotpos+1, file.name.length); extension = extension.toLowerCase(); //Added code }

          ...

          That seemed to do the trick. Now I can add image filenames that end with .SVG, .JPG and .GIF and they embed nicely. Thanks Davo.

          Show
          frankiekam Frankie Kam added a comment - - edited BTW, taking a cue from your discovery of how to cure the bug, I added this line of code: extension = extension.toLowerCase(); inside the handle_file function of the file named moodle/course/dndupload.js (in my Moodle Production site) handle_file: function(file, section, sectionnumber) { var handlers = new Array(); var filehandlers = this.handlers.filehandlers; var extension = ''; var dotpos = file.name.lastIndexOf('.'); if (dotpos != -1) { extension = file.name.substr(dotpos+1, file.name.length); extension = extension.toLowerCase(); //Added code } ... That seemed to do the trick. Now I can add image filenames that end with .SVG, .JPG and .GIF and they embed nicely. Thanks Davo.
          Hide
          davosmith Davo Smith added a comment -

          I have just added changed the line to

          extension = file.name.substr(dotpos+1, file.name.length).toLowerCase();

          locally.

          Will submit a proper patch for integration (and cherry-picked to 2.3, 2.4, as it will affect those branches as well) later this evening.

          Show
          davosmith Davo Smith added a comment - I have just added changed the line to extension = file.name.substr(dotpos+1, file.name.length).toLowerCase(); locally. Will submit a proper patch for integration (and cherry-picked to 2.3, 2.4, as it will affect those branches as well) later this evening.
          Hide
          davosmith Davo Smith added a comment -

          Cherry-picked onto 2.3/2.4 as the zip file handling is also affected by case (plus any 3rd-party add-ons that happened to handle dragged and dropped files with specific extensions).

          Show
          davosmith Davo Smith added a comment - Cherry-picked onto 2.3/2.4 as the zip file handling is also affected by case (plus any 3rd-party add-ons that happened to handle dragged and dropped files with specific extensions).
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Integrated (23, 24 & master), thanks!

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Integrated (23, 24 & master), thanks!
          Hide
          abgreeve Adrian Greeve added a comment -

          Tested on the 2.3, 2.4 and master integration branches.
          Step one (uploading images to the master branch)
          Worked fine as described.
          Step two (uploading zip files)
          Worked fine in master
          2.3 and 2.4 - Files with the extension capitalised would load as a zip resource, but would not show the pop up window offering different options such as SCORM.
          files with a lower case extension work fine in all branches.

          Show
          abgreeve Adrian Greeve added a comment - Tested on the 2.3, 2.4 and master integration branches. Step one (uploading images to the master branch) Worked fine as described. Step two (uploading zip files) Worked fine in master 2.3 and 2.4 - Files with the extension capitalised would load as a zip resource, but would not show the pop up window offering different options such as SCORM. files with a lower case extension work fine in all branches.
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          ping!

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - ping!
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Sorry, Adrian, I just tested dropping one .ZIP file under 23_STABLE and I get the dialog asking for folder/file resource/scorm.

          Can anybody else verify?

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Sorry, Adrian, I just tested dropping one .ZIP file under 23_STABLE and I get the dialog asking for folder/file resource/scorm. Can anybody else verify?
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Also tried 24_STABLE. Working too (I get the list of choices dropping .ZIP)

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Also tried 24_STABLE. Working too (I get the list of choices dropping .ZIP)
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment - - edited

          I've just tested again into brand-new integration.git 23 and 24 stables and I'm getting .ZIP (and .zip) both showing the alternatives.

          So, I'm going to send it back to testing to confirm it was a problem in tester environment (and not in mine).

          Adrian, could you plz, verify the .ZIP behavior under 23, 24 and master once more? (purging caches, forcing reload... whatever it's needed to get the JS updated).

          TIA and ciao

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - - edited I've just tested again into brand-new integration.git 23 and 24 stables and I'm getting .ZIP (and .zip) both showing the alternatives. So, I'm going to send it back to testing to confirm it was a problem in tester environment (and not in mine). Adrian, could you plz, verify the .ZIP behavior under 23, 24 and master once more? (purging caches, forcing reload... whatever it's needed to get the JS updated). TIA and ciao
          Hide
          abgreeve Adrian Greeve added a comment -

          Tested again. It's working now. I can only guess that I hadn't purged the caches (which continues to hamper my testing career).
          Sorry for the hold up.
          Test passed.

          Show
          abgreeve Adrian Greeve added a comment - Tested again. It's working now. I can only guess that I hadn't purged the caches (which continues to hamper my testing career). Sorry for the hold up. Test passed.
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Thanks!

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Thanks!
          Hide
          damyon Damyon Wiese added a comment -

          Thanks for your hard work - this issue has made it! Moodle is now a little bit better.

          Regards, Damyon

          Show
          damyon Damyon Wiese added a comment - Thanks for your hard work - this issue has made it! Moodle is now a little bit better. Regards, Damyon

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Mar/13