Support

Account

Home Forums ACF PRO File type: Possible to rename on upload?

Solving

File type: Possible to rename on upload?

  • Is there any way (yes, I’m okay with PHP if there is a hook or something) to rename each file being uploaded based on the value of another field? I would like to force my files to be named in a consistent manner, rather than something random that the user happened to call it on his computer.

    A bonus would be if I can also control the directory it goes on (instead of year and month it was uploaded), so that the files don’t get mixed in with photos and such.

  • Hi @osakawebbie

    Thanks for the question. I don’t believe this is possible unfortunately.
    ACF piggy backs the core media uploader for all file/image uploading functionality. It may be possible to find some filters/actions on google which allow you to modify the directory / file name, but these would be core filters/actions, not ACF ones.

    Thanks
    E

  • You may check WP filter wp_handle_upload_prefilter it seems to be what were you looking for. See https://developer.wordpress.org/reference/hooks/wp_handle_upload_prefilter/. As an example of usage you may check this plugin https://wordpress.org/plugins/clean-image-filenames/ which cleans uploaded files names.

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

You must be logged in to reply to this topic.