Skip to content

Instantly share code, notes, and snippets.

@mmilosheski
Last active December 14, 2016 19:46
Show Gist options
  • Save mmilosheski/5eaa13a1b7e1b821ac772fe7d3a2747e to your computer and use it in GitHub Desktop.
Save mmilosheski/5eaa13a1b7e1b821ac772fe7d3a2747e to your computer and use it in GitHub Desktop.
/*mile test */
function make_filename_hash($filename) {
if( isset($_REQUEST['post_id']) ) {
$post_id = (int)$_REQUEST['post_id'];
}else{
$post_id=0;
}
$info = pathinfo($filename);
$ext = empty($info['extension']) ? '' : '.' . $info['extension'];
$name = "imported";
if($post_id>0){
return get_the_title($post_id)."_".$name . $ext;
}else{
return $name . $ext;
}
}
add_filter('sanitize_file_name', 'make_filename_hash', 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment