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

Cannot change image when editing (html editor)



    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.0.2
    • Fix Version/s: None
    • Component/s: Files API
    • Labels:
    • Affected Branches:


      It should be possible to upload a new version of an image you have made for (e.g.) a forum post without renaming it. There may actually be two issues here...

      To reproduce:

      1) Create new forum post. Add an image called image.jpg (uploaded from your hard disk). Save the post.

      2) Edit the forum post. Delete the existing image (e.g. select it, press Del).

      3) Immediately add a new image, again using upload. On your hard disk, select a different file that is also called image.jpg (imagine this as a person who has made the image, but now changes it slightly and saves changes).

      4) When you click the button to upload the new file, you get a popup error 'File name already being used, please use another name'

      This error is incorrect; the file name is not being used any more, because it was deleted.

      5) Cancel out of the image dialogs but save the edited post, so that it now does not contain any image at all (and this change has been saved).

      6) Edit the post again.

      7) Add the image again as in step 3.

      The same error appears (now it is even more incorrect).

      So there may be two issues here:

      • (step 3) file api code doesn't notice that somebody has used various tinymce UI to delete the image. I can imagine this is probably difficult to fix.
      • (step 7) after saving the post, the file api (save_draft_area_files or something?) does not notice that the previously-in-use images are no longer present in the html. Ideally it should detect this as part of the replacing it does, and remove the file references.

      It would also be possible to workaround all such cases by making it automatically change the filename e.g. to add _1 or _(n+1) if it already has _n at the end before extension. This might be a better solution.

      Anyway - not sure any action is needed but our testers reported this so I thought I would check and file it.


          Issue Links



              skodak Petr Skoda
              quen Sam Marshall
              Component watchers:
              Matteo Scaramuccia, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              0 Vote for this issue
              0 Start watching this issue