Uploading Olympus images lose titles
-
I run a photo club website and am having to spend a lot of time correcting the photo and Captions which both say OLYMPUS DIGITAL CAMERA whereas on the filename has the required name. Other camera brands seem fine.
-
Hi there,
Unfortunately, that is the case and according to this link it is considered as wont fix:
https://core.trac.wordpress.org/ticket/32378
You are welcome to ask again there to see if there is a chance to re-consider that.
Best regards,
Christopher Amirian
I found this snippet which copies filename to title when uploading, except its the full path – I need to strip the filename without path and extension. ANy help please?
/** * Override the meta title for jpeg/tiff images * * @link http://wordpress.stackexchange.com/a/192779/26350 */ add_filter( 'wp_read_image_metadata', function( $meta, $file, $sourceImageType ) { $image_types = [ IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ]; if( ! empty( $meta['title'] ) && in_array( $sourceImageType, $image_types ) ) $meta['title'] = ''; // <-- Edit this to your needs! return $meta; }, 10, 3 );
Hi there,
Maybe this change can help?
/** * Override the meta title for jpeg/tiff images * * @link http://wordpress.stackexchange.com/a/192779/26350 */ add_filter( 'wp_read_image_metadata', function( $meta, $file, $sourceImageType ) { $image_types = [ IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ]; if( ! empty( $meta['title'] ) && in_array( $sourceImageType, $image_types ) ) { // get filename without path $filename = basename($file); // strip extension from filename $filename_no_ext = pathinfo($filename, PATHINFO_FILENAME); // set title to filename without extension $meta['title'] = $filename_no_ext; } return $meta; }, 10, 3 );
The code uses the
basename()
function to get the filename, and thepathinfo()
function to strip out the extension.This code will modify the title to be the filename without extension for JPEG and TIFF images. Please ensure you backup your site before making any changes, and test this in a safe environment before implementing on a live site.
Perfect.
Thanks
My pleasure 🙂
- The topic ‘Uploading Olympus images lose titles’ is closed to new replies.