If you are uploading via Core admin pages, WordPress will most likely upload the file, and then create an attachment
post– that is, a post with the attachment
post type. So the save_post_attachment
hook might do it for you.
3362 /**
3363 * Fires once a post has been saved.
3364 *
3365 * The dynamic portion of the hook name, `$post->post_type`, refers to
3366 * the post type slug.
3367 *
3368 * @since 3.7.0
3369 *
3370 * @param int $post_ID Post ID.
3371 * @param WP_Post $post Post object.
3372 * @param bool $update Whether this is an existing post being updated or not.
3373 */
3374 do_action( "save_post_{$post->post_type}", $post_ID, $post, $update );
It is hard to be very specific given how general the question is.
Related Posts:
- Saving Custom Field in Attachment Window in WordPress 3.5
- How to save media files under custom folder without changing wp-config.php or changing media settings
- How to add upload video option in wordpress for user?
- Custom dropdown field added to media gallery; how to get it to save properly?
- WordPress Media Uploader custom Javascript not working
- display custom media folders to wordpress media popup
- How can I create more “create attachment” custom field – any idea?
- Media Custom Fields – get a value with PHP
- How to Protect Uploads, if User is not Logged In?
- How to Fix HTTP Error When Uploading Images?
- Extend Media Library
- WordPress 3.5: Setting custom “full URL path to files” in the Media Library?
- Upload images to remote server
- How to show all available images in WP’s media library when using the Polylang plugin?
- Which filters or actions to use after a media upload and delete?
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- How to wp_upload_bits() to a sub-folder?
- Change Media Uploader default directory
- How to hide media uploads by other users in the Media menu?
- “Add Media” only shows “Full Size” under Attachment Display Settings
- Where do the favicons for Media Files come from
- Change behavior of “Insert into Post” based on attachment metadata
- Is it possible to trigger some JavaScript when Media Popup is opened?
- How to call WP3.5 Media Library manager?
- Creating a metabox to upload multiple images, Ignoring The Featured Image
- Password protect some uploaded files, so only logged-in users can view them
- Attach Files Metabox
- How to protect uploads in multisite if user is not logged in?
- Using media-upload.php to upload mp3 via custom fields
- Add new “Insert Into Post” button with another function
- Append button to WordPress Image Details modal
- Extend WP Customizer to make multiple image selection possible
- Ignore a filter on the media library
- WP3.5 Media Uploader – how to make it accept multiple images?
- Custom bulk action for media gallery items
- How to Removing fields from the Media Uploader/Gallery on a Custom Post Type Edit Page
- Restricting access to files within a specific folder [duplicate]
- How to save custom fields for attachments
- WordPress custom upload field error
- Media items hogging pretty permalinks
- limit amount of photos uploaded per cpt post
- WordPress media upload “HTTP error”
- How to disable WordPress Media resize different size version?
- Restrict file types in the uploader of a wp.media frame
- Metabox with multiple fields added by user and upload box
- Metabox image upload and custom field
- Media library storing files in uploads not folders within in uploads
- Add select field to media uploader that adds a class to the image
- Custom image sizes for custom field media uploads
- wp_handle_upload error “Specified file failed upload test” but still creates attachment?
- How to host different file formats/types for a media attachment without creating multiple attachments?
- How to import 55k images (uploaded via FTP) into WordPress Media libary? [closed]
- Different upload path per file type
- Site icons with alpha channel for self-hosted WordPress blog network
- How to retrieve alt attribute for an attachment (uploaded image)?
- Insert attachment ID in custom field from media uploader
- How do I get allowed Media Library upload file extension list?
- Cannot upload .mp3 file to wordpress media
- HTTP Error when uploading files above 7mb unless using GD Image Editor
- Duplicate Custom Header Functionality into the post edit screen
- How to replicate Media Library “Add New” on Plugin Settings Page
- How can I store a file in the database in the same way WordPress and ACF do?
- Switch between tabs on “Insert Media” dialog
- Bulk edit of EXIF data for jpeg images uploaded in the media library?
- Cannot upload anything via wordpress
- How organize uploaded media in WP?
- How do i save and retrieve custom attachment meta?
- How do I modify the “Insert Media” lightbox in the admin to only show media items from a category?
- Restrict WordPress Media Library for a specific user role (users can only see/select own media)
- Display attachments by the ID of the post being edited in the wp.media frame (frontend)
- Uppload image from another source wp.media
- Multisite – Images often getting uploaded to the wrong month directory
- Is there a simpler version of WP Media?
- move_uploaded_file() not working on wordpress front end
- WordPress Issue : The uploaded file could not be moved to wp-content/uploads/
- Convert (-) and (escape) signs to (_) when uploading files on wordpress media library automatically
- modify wordpress caption shortcode
- Client PDF Upload (Catalogue) – Automatically update link to PDF
- Using wp_enqueue_media() with switch_to_blog() issue
- How to upload WordPress Images to remote web server and display those images in WordPress gallery [closed]
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- How to get the return value of wp.media({ frame: ‘post’ }) in all cases?
- Media library only shows for admin. Doesn’t show editor or below [closed]
- WordPress media uploader – upload tabs not hiding
- Images uploaded to the media library has strange colors. However, in the edit screen the color is ok
- Uploading PDF using Media Uploader
- Select multiple images from custom field
- Redirect to another page using contact form 7? [closed]
- Too slow Image upload in WordPress Media Library as image number increases
- upload_max_filesize is set to 64 MB already but WordPress is still showing 2 MB
- PHP error when trying to upload .mp3 files via Media Library [closed]
- 3.8 Media Upload and Custom Meta Box
- Get images attached to a specific page
- A link (not in the post) to download a specific PDF file
- Display MP3 as media using an URL from a custom field
- How to use media upload on metabox post page without breaking TinyMCE?
- Migrating media files (documents only) to a fresh install and maintaining the same directory structure
- How does wordpress handle media files?
- wp.media issue with selected image
- Is there a way in WordPress to convert images to WebP without a plugin?