Home Forums Add-ons Repeater Field Renaming a photo upon upload Reply To: Renaming a photo upon upload

  • It is possible to change the file name of an uploaded file during the upload in WP, you can do a search for this and find several solutions, however, it’s not possible to do what you’re looking for. The reason is that the field with the stock number won’t be available until after the image is already uploaded and saved to the uploads folder. When you add an image in ACF the image is uploaded and then then actual value of the field is the image ID that was uploaded.

    Giving this some thought, you could rename the file after the upload once the post is submitted. Well, not really rename it exactly, more like replace it. You could create an acf/save_post filter and in this filter

    1. Get the information about the image that was uploaded
    2. use this information to insert a new image with the altered file name using
    3. Update the ACF field with the ID of the new image
    4. Delete the first image with