Problem/Motivation

When uploading an image through the WYSIWYG editor in the Advanced HTML/Text editor, the image is not saved as a drupal managed file. The image itself does upload at the time to sites/default/inline-images, however, coming back a day later the image has been deleted resulting in a 404.

Steps to reproduce

  1. Create new form and add an Advanced HTML/Text editor element
  2. Upload an image through the WYSIWYG editor
  3. View the form and confirm your image is there
  4. At this point, not sure how or when the deletion gets triggered, but the image is deleted from the sites/default/inline-images directory resulting in a 404. This happened twice to me in 48 hours. I thought running cron would trigger the deletion but it didn't.

Proposed resolution

I think when uploading the image, the image needs to be saved using file_save_data or file_save_upload and then using the 'file.usage' service to register the usage of the file which will automatically mark it as permanent.

Comments

rondog469 created an issue. See original summary.

  • jrockowitz committed d7bbd02 on 2983137-editor-file-upload
    Issue #2983137: WYSIWYG editor not saving inline images for advanced...

  • jrockowitz committed ca0e182 on 2983137-editor-file-upload
    Issue #2983137: WYSIWYG editor not saving inline images for advanced...

  • jrockowitz committed c4c6f09 on 2983137-editor-file-upload
    Issue #2983137: WYSIWYG editor not saving inline images for advanced...
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new10.2 KB

Attached patch just fixes file upload to webform entities. It does NOT fix files uploaded to webform.settings.yml.

Status: Needs review » Needs work

The last submitted patch, 5: 2983137-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • jrockowitz committed 6f61caf on 2983137-editor-file-upload
    Issue #2983137: WYSIWYG editor not saving inline images for advanced...
jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new10.28 KB

  • jrockowitz committed 55a7bcb on 2983137-editor-file-upload
    Issue #2983137: WYSIWYG editor not saving inline images for advanced...

  • jrockowitz committed 60ba5ac on 2983137-editor-file-upload
    Issue #2983137: WYSIWYG editor not saving inline images for advanced...

  • jrockowitz committed 5eb974b on 2983137-editor-file-upload
    Issue #2983137: WYSIWYG editor not saving inline images for advanced...
jrockowitz’s picture

StatusFileSize
new33.42 KB

  • jrockowitz committed 11a653f on 2983137-editor-file-upload
    Issue #2983137: WYSIWYG editor not saving inline images for advanced...

  • jrockowitz committed 117c601 on 2983137-editor-file-upload
    Issue #2983137: WYSIWYG editor not saving inline images for advanced...
jrockowitz’s picture

StatusFileSize
new42.62 KB

  • jrockowitz committed b939778 on 2983137-editor-file-upload
    Issue #2983137: WYSIWYG editor not saving inline images for advanced...
jrockowitz’s picture

StatusFileSize
new42.05 KB
jrockowitz’s picture

This patch is done and needs review.

  • jrockowitz committed de906b7 on 2983137-editor-file-upload
    Issue #2983137 by jrockowitz: WYSIWYG editor not saving inline images...
jrockowitz’s picture

StatusFileSize
new43.77 KB
jrockowitz’s picture

Status: Needs review » Reviewed & tested by the community
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

  • jrockowitz committed 46605d8 on 8.x-5.x
    Issue #2983137 by jrockowitz: WYSIWYG editor not saving inline images...
  • jrockowitz committed 8244ae5 on 8.x-5.x
    Issue #2983137 by jrockowitz: WYSIWYG editor not saving inline images...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rondog469’s picture

thank you, Jacob!

drubage’s picture

We are still seeing this issue with 8.x-5.1. If an image is uploaded via the WYSIWYG editor into an "Advanced HTML/Text" field on a webform then the image is considered "temporary" and deleted by Drupal during file cleanup. Is this patch in 5.1 or is this still an outstanding issue?

amuhlou’s picture

We are still seeing this issue with the 8.x-5.x version as well. Images uploaded in the Advanced HTML element seem to stick around for about 2 weeks and then disappear completely off the server.

berdir’s picture

The chance that someone sees comments in a closed ticket are slim. instead of commenting here, it is recommended to create a new issue and cross-reference it. Did that now here: #3197928: Inline images in Advanced HTML elements are temporary and deleted