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


Multiple Image Fields: Editing one image affects both on save

  • I’m encountering an issue with WordPress and the ACF plugin. In my current setup, I have a repeater field that includes two image fields. The problem arises when I upload the same image to both fields and proceed to edit one of the images.

    Upon saving the changes, I noticed that both images are modified, despite my intention to edit only one. It appears that WordPress is not preserving the reference to the selected image (original), causing the edits to apply to both fields.

    Has anyone else experienced a similar issue? Is there a way to ensure that changes made to one image field are isolated and do not impact the other?

    I would greatly appreciate any insights, workarounds, or suggestions on how to resolve this problem. Thank you for your help!

  • ACF only stores the ID of the image. If you add the same image to 2 fields this does not create 2 images but 2 references to the same image. When you edit the image in WP it will effect all uses of the image.

  • Hello John, thank you for your response! You have confirmed what I thought.

    Do you have any recommended workaround for this issue? I mean, I have tried to hook for the image-edit action so that I can create a physical copy of the image. However, I have not been able to determine the best approach or find any effective workarounds yet.

    The only viable solution I can see now is to upload an additional image (a copy of the original) to assign it a different ID.

    Thank you!

  • 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.

  • I forgot something else, you’d also need to figure out how to hook into what is returned to ACF and update the image field with the new image that was just created. Something else I don’t know.

    Your best, simplest solution would be to upload a new image.

  • Hello John, thank you for your comprehensive response.

    I have also invested some time in trying to find a solution to this problem, but unfortunately, I have not been successful. It strikes me as peculiar that there are so few threads with similar issues on the internet, considering it appears to be a fairly common issue.

    Nevertheless, I will attempt a few more potential solutions, such as using a hook before the WP function. However, for the time being, I will likely resort to manually uploading a duplicate image.

    Once again, I sincerely appreciate your assistance and the time you have dedicated to helping me.

    Have a great day!

    Best regards,


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.