Image Advanced field "Force delete" option doesn't work

Support General Image Advanced field "Force delete" option doesn't workResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #24099
    AshAsh
    Participant

    When I delete a post that has Image Advanced filed, attached image won't be deleted.
    This might be compatibility problem with WPML.(not sure)

    #24100
    AshAsh
    Participant

    Actually disabling WPML doesn't affect the problem.

    #24101
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The option 'force_delete' => true is to delete the media file when removing it from the post meta (list images of image_advanced field). See my screen record for more information https://share.getcloudapp.com/v1u4Z8BD.

    #24106
    AshAsh
    Participant

    As I mentioned, Force delete is enabled in Metabox Builder.

    #24110
    Long NguyenLong Nguyen
    Moderator

    Hi,

    I also use the MB Builder on the screen record. The documentation also notes about this setting:

    force_delete Whether or not delete the images from Media Library when deleting them from post meta. true or false (default).

    Delete the image from the list of the field which is created by Meta Box - post meta, not delete the image when deleting the post.

    #24111
    AshAsh
    Participant

    I see.
    Is there a way to delete attached images when a post is deleted?

    #24112
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Actually, after deleting a post, the post meta is still stored in the database. So I think you should:
    1. Delete the attachment (image).
    2. Delete the post meta.

    The action hook before_delete_post will help you to achieve the goal.

    Refer to this topic: https://wordpress.stackexchange.com/questions/134894/correctly-delete-posts-with-meta-and-attachments

    and some WP functions:
    https://developer.wordpress.org/reference/functions/wp_delete_attachment/
    https://developer.wordpress.org/reference/functions/delete_post_meta/

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.