I figured out how to retitle the attachment myself, using a combination of the answers from these two posts:
How can I add a default description to uploaded files?
Here’s the code, it’s working on my current WP installation (v4.3)
function wpse_retitle_attachment( $post_ID )
{
$file = get_attached_file($post_ID);
$path = pathinfo($file);
$args = array(
'ID' => $post_ID,
'post_title' => $path['filename'] . "." . $path['extension'],
// 'post_excerpt' => 'My default caption ...',
// 'post_content' => 'My default description ...',
);
wp_update_post( $args );
}
add_action( 'add_attachment', 'wpse_retitle_attachment' );
Related Posts:
- Insert Media – Attachment – Link to : Remove the “attachment page” option
- Automatically deactivate link for attachments
- How to get boolean if file A is attached to post B
- Open attachments in new tab/window
- How To Retrieve An Image Attachment’s Alt Text?
- How to get attachment file name not attachment URL
- Programmatically adding images to the media library with wp_generate_attachment_metadata randomly fails
- How to cleanly delete attachment but retain original file?
- Trying to hide buttons from Attachment window
- Uploading Multiple Attachments From Front-End With A Description
- Validate alt text for attachments?
- complex restriction of items in media library
- Edit image / Delete image link
- How could I add button next to “edit image” button in “Attachment Details”
- Get all posts (of any post type) an attachment is used in
- Give attachments an archive page
- Can I attach a document (eg: PDF) but have a JPEG as a thumbnail?
- Retrieving a custom link on an attachment
- How can I display custom fields value from attachment media?
- how to test for attached image
- Unable to upload specific .zip file type via frontend in WordPress 4.0
- get post attachments of a particular size
- Add_Filter example for wp_get_attachment_link
- Can i hide the attachments from media which I uploaded from front end?
- attachment url rewrite
- Automatically delete attachments and posts [closed]
- How to delete orphan attachments?
- Get the title and URL of the attachment parent post
- Confused with attachment mimetype order
- Disable edit media attachments?
- query attachment images … if no attachments -> get attachments of parent page?
- Replacing with(out) regex link to attachment by links to files
- Post Auto Draft Issue
- Getting attachment images is cloning some of them
- rename attachments based on parent-post-title on upload
- Rename attachments during upload no matter what filetype
- Link all WordPress images size
- post_author for wp_insert_attachment
- Contact Form 7 Data As Attachment [closed]
- Post Via Email – How to send Attachments with it (e.g. PDF File or JPEG Image)?
- Displaying Post Attachment(s) at Top of single.php
- Detach an image from a page using php
- Get the path of the first attached media (single.php)
- Ordering of gallery images without using shortcode in theme
- Adding width and height to wp_get_attachment_image_src
- custom admin thumbnail for videos, not getting post’s id?
- Custom Gallery HTML only working when images are attached to post/page
- Image Gallery Numbers for 3.5
- Control attachments menu order with jQuery Sortable
- Link Attachment Image to Category
- How to delete a custom file from upload directory when deleting its post
- Media library quick/inline edit
- Check what attached image size is used
- Query to only return the 2 newest post attachments (images)?
- Clean up images, delete unused image sizes attached to a post type
- Custom image sizes add to metadata
- What is the best way to store thumbnails for a non-image attachment?
- Change default selection for “Embed or Link”?
- Can’t filter wp_get_attachment_link
- What will happen if I delete all my attachment type posts from database?
- filter get_children to return all mime types EXCEPT ‘x’
- Weird string offset errors when displaying post attachments
- Add audio attachment link to RSS
- Links to my uploads went crazy
- hide attached images of a post
- How to add a caption to an image attachment in a file list?
- Unable to get wp_get_attachment_url to show
- has_excerpt yields true but no post_excerpt when retrieved
- Hiding or removing file extension displayed in HTML on attachment page
- After changing permalink structure, How to redirect attachment url to old parent post url
- Possible to add “Even/Odd Classes” to image attachments via wp_get_attachment_image?
- Can’t sort get_posts by post_mime_type
- How to list “invisible” Auto Drafts?
- How to add media from front-end to an existing post and edit file title
- How is it possible that a gallery doesn’t have attachment ids?
- Were attachment media settings removed from WordPress?
- How to identify and delete all the images/pdf’s which are not assigned to any post/custom-post/page and also which are repeated
- Media item permalink goes to source file instead of attachment.php
- Nothing found in uploads folder after wp_insert_attachment
- Display audio file in audio.php
- PHPMailer – Uploading a file
- Attachment file display link text
- Get video attachment ID and display length
- missing attachment are showing as 404
- Insert attachments from front end form
- How do I add Facebook OpenGraph meta tags for attachments in the header for a custom theme?
- Add link to attachment for old posts
- Drupal 6 to WordPress migration – media attachments
- Retreive tags from attached post for media on page
- Move caption in on attachment page
- How can I let users access a specific attachment?
- How to wrap this Link with an Image?
- How to save media-form on custom tab
- get_image_tag filter not working
- Change attachment inside the_content using filters
- Bulk delete media by year
- Count images in post then add class if just one
- One audio attachment, with two possible interchangeable extensions
- Attachement Meta DATA
- Media library upload hook