2

I know this type of questions asked before but, i want image rename in my layout

how can i rename the image on uploading with wordpress upload.

Here is my image rename layout

lsp_image name_datetime.ext

Anyone please help me

5

1 Answer 1

4

ok i find the solution to rename the image on upload

here is my solution:

function lsp_rename_image($filename) {
    $info = pathinfo($filename);
    $ext  = empty($info['extension']) ? '' : '.' . $info['extension'];
    $name = basename($filename, $ext);
    return "lsp_".$name."_".date('dmy-his').$ext;
}
add_filter('sanitize_file_name', 'lsp_rename_image', 10);
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.