Support

Account

Home Forums General Issues Multiple Image Fields: Editing one image affects both on save Reply To: Multiple Image Fields: Editing one image affects both on save

  • I did a search and could not find any information on duplicating an image before applying edits. I find it odd that no one has looked into this before but that appears to be the case. I also looked into the WP functions and see not hooks that could be used to allow duplication of an image before the edits are applied.

    It might be possible, but I’m not sure.

    When you save changes in the image editor the hook “wp_ax_image_editor” is fired. You can see the WP function in /wp-admin/includes/ajax=actions.php LINE: ~2644.

    This function gets the post ID of the image being edited from $_POST[‘postid’].

    It might be possible to add your own action that runs before the WP function

    
    add_action('wp_ajax_image_editor', 'YOUR FUNCTION NAME', 1);
    

    In your function you can inspect the input in $_POST and if the file is being saved you could then duplicate the original image and return then alter $_POST[‘postid’] to hold the new ID of the new image.

    I’m not sure about how to go about duplicating an image.