Currently Wordpress gets an attachment name from the exif title value for images:
<?php
// Use image exif/iptc data for title and caption defaults if possible.
} elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = wp_read_image_metadata( $file ) ) {
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
$title = $image_meta['title'];
}
Is there any way to save the original filename to the database? I've tried bunch of filters and hooks without any result.
https://developer.wordpress.org/reference/functions/media_handle_upload/
Possible solution could be to use sanitize_file_name filter to get $filename_raw and insert it to custom table with the sanitized $filename.
To get the original filename later we just need to query the custom table while comparing sanitized filenames to attachment filenames.
Am I right or is there any other way?
guid
column of the post table for that attachment?