Inline images in the answer field are removed during file garbage collection

Created on 8 June 2016, over 8 years ago
Updated 27 February 2024, 9 months ago

Problem/Motivation

If you place a file in the answer formatted text field it is not marked as a permanent file and, if the site is configured to remove temporary files, it is deleted on cron. This is contrary to what happens with other text fields.

The issue arises from the Editor module. The function _editor_get_formatted_text_fields(), which is used to determine whether a given field should be scanned for embedded files, includes a hard-coded list of field types:

array('text', 'text_long', 'text_with_summary')

Because the FAQ field is not in this list, it is not recognized as a formatted text field and so ignored.

Proposed resolution

Possible fixes:

  • In a new core issue, propose a new alter hook that would be invoked in _editor_get_formatted_text_fields() to allow modules to register their field types as including formatted text, then implement the hook.
  • Refactor FAQ field to use a core field directly.
  • Replicate the complex handling that's in Editor.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Needs review

Version

7.1

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany marcusx

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • @kasperg opened merge request.
  • πŸ‡©πŸ‡°Denmark kasperg

    This issue has been closed, potentially waiting for #2732429 to be resolved.

    I took a stab at resolving the initial issue and have provided the related changes needed for the FAQ field module in a merge request here.

  • Status changed to Active almost 2 years ago
  • πŸ‡©πŸ‡°Denmark kasperg

    I'll reopen this issue to indicate that there is a potential fix for this.

  • πŸ‡ΊπŸ‡ΈUnited States hershy.k

    hershey.k β†’ made their first commit to this issue’s fork.

  • Status changed to Needs review 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States hershy.k

    The code changes from MR #2 appeared to be missing something. The interface used in the code was non existent in the codebase.

    As noted in #5 πŸ› Inline images in the answer field are removed during file garbage collection Active ideally the custom answer text field data structure would need to be refactored to support this capability even with core's commit in https://www.drupal.org/project/drupal/issues/2857444 β†’ .

    The approach taken in MR #6 attempts to make a minor code change that would allow for support for inline-image file status to be controlled by core's editor module without refactoring the answer field's data structure.

    I also updated the category to a "Feature request" as it's not technically a bug but a feature that has never been supported AFAIK.

    To test functionally:
    - Enable faqfield module and add a faqfield type to a content type
    - Use WYSIWYG formatter to upload inline-image file to answer textfield
    - Save entity and verify the status of the file uploaded to system accurately reflects a permanent status in the admin file list view

Production build 0.71.5 2024