وردپرس

Rename File Uploads | WordPress.org


I love the custom file path feature, and I think renaming the file on upload would be ideal.

I tried using this snippet:

// ACF Upload Prefilter:
add_filter('acf/upload_prefilter/name=some_file_upload', 'acf_upload_prefilter' );
function acf_upload_prefilter() {
// WP Handle Upload Prefilter:
add_filter('wp_handle_upload_prefilter', 'rename_current_acf_upload', 11, 1);
}
function rename_current_acf_upload( $file ){
$file['name'] = 'custom-filename-' . $file['name'];
return $file;
}

Which works if run in the backend, but not if uploaded/updated through the ACF Form provided through frontend admin.

I notice though that the file does get renamed with the field id appended, so it looks like this is already happening to some extent….but I would love to be able to rename the file using the $post_title + ‘custom-filename’.[same extension]

Is there a hoook or filter I can use to hook into renaming the file upload for specific fields?

THanks!

این خبر را در ایران وب سازان مرجع وب و فناوری دنبال کنید

مشاهده پاسخ های این مطلب
———————————————
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد

منبع: انجمن وردپرس

دکمه بازگشت به بالا