Closed oferlaor closed 11 months ago
OK, got this to work:
function the_paste_default_filename() {
return "Pasted<username>-%s";
}
The problem is that both my postname and username values are not in English, which is not a good idea for media. Is there a way to add
Okay, "Default file name" might be a bit misleading, I admit. Primarily it is the attachment title. The actual filename is generated through sanitize_file_name()
.
After pasting and confirming the image dialog, the plugin is passing the file object to WordPress to handle the upload. It is exactly what happens when you drop a file from the OS from that point. WordPress only strips out characters that could interfer with the OS – like directory separators, quotes end so on – leaving the rest intact. (I tried this with a chinese filename.)
Hooking into sanitize_file_name
sounds like a better place to strip out or transform invalid characters.
It’s not actually important to fix sanitationJust want more options In the default naming. Namely:1. Post ID 2. Author ID3. Author username (instead of full name)Is it possible?Best regards,Ofer LaOrOn 25 Sep 2023, at 10:59, Jörn Lund @.***> wrote: Okay, "Default file name" might be a bit misleading, I admit. Primarily it is the attachment title. The actual filename is generated through sanitize_file_name(). After pasting and confirming the image dialog, the plugin is passing the file object to WordPress to handle the upload. It is exactly what happens when you drop a file from the OS from that point. WordPress only strips out characters that could interfer with the OS – like directory separators, quotes end so on – leaving the rest intact. (I tried this with a chinese filename.) Hooking into sanitize_file_name sounds like a better place to strip out or transform invalid characters.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
this doesn't seem to do the trick:
Is there an example of how to use these two filters?