WordPress’ media handling strikes me as scattered and inconsistent. I say that only to say that I can’t promise this will work in all cases. However, I think I’d use the add_attachment
hook from wp_insert_attachment
.
You will get a post ID, so you will have to …
- retrieve the image src with
wp_get_attachment_imge_src
,
probably, - retrieve the image itself and process it (not sure how you intend to
do that), - and save the extra data.
Related Posts:
- Filter to modify post_title after image upload?
- How to display a warning when an uploaded image is too small?
- How to trigger “wp_handle_upload_prefilter” filter when uploading an image programatically?
- Rename uploads filenames to POST-ID on upload
- Filter to remove image dimension attributes?
- Each custom image size in custom upload directory?
- How to delete resized (cropped) image uploads and prevent future resizing?
- After Moving a Site to Another Domain, All Images Are Lost
- Is there a hook which fires after all thumbnails are generated?
- Using Images in WordPress – Best Practices
- Prevent large image uploads
- Modifying an uploaded image with ‘wp_get_image_editor’ and ‘wp_handle_upload_prefilter’
- Change html structure of all img tags in WordPress
- How to copy and paste a picture found on the web to wordpress easily
- Disable resizing of gif when uploaded
- Get attachment ID of author_meta image – Attachment Metadata
- How can you upload an image from within a settings page?
- Alter image output in content
- How can I remove the image attachment ALT field?
- How to Display an Image Uploaded through a Meta Box in a Template?
- could not upload image in media library
- Change html structure of all img tags in WordPress
- When Uploading JPEGs, Does WordPress Compress the Original Image?
- Uploading images: ‘ø’ get replaced with ‘ø’
- SSL: How to make customizer images Protocol Relative in WordPress?
- Insert image in comment reply
- Images in upload folder with hexadecimal names
- How to get image ID to use inside wp_read_image_metadata()?
- How to remove Geo Tagging on image uploads, but not other EXIF data?
- Is there any action/filter hook to use when an image gets edited in the editor?
- Faster way to put images into a blog post by using Add Media dialog
- Handling image uploads without thickbox
- Disable all resizing and compression
- Loose images in uploads folder
- Force minimum image size and aspect ratio when uploading images
- having issue while uploading An error occured in the upload. Please try again later
- WP fails to upload files to media library, /wp-admin/async-upload.php 403 forbidden
- Add a background image for Custom Post Type archives page
- Convert uploaded GIF to non animated image automatically
- Is it possible to split Default WP Media directory to multiple Folder/Subdomain?
- Change align classes for images
- Ho to add “Create Slider” option to default “Add Media” popup?
- Images in Media aren’t showing, not broken
- How to replace images?
- Upload Image using wp_insert_attachment and file url don’t have file extension
- using media_sideload_image with a file from theme directory
- Images uploaded to the media library has strange colors. However, in the edit screen the color is ok
- Blank upload.php page
- Add custom text in the media library image meta area
- Upload image without media-upload [duplicate]
- Tinymce and uploading local pictures
- Unable to upload images to the Media Library. Getting this erron on the console wp-admin/async-upload.php 403 (Forbidden)
- How to get the Gallery form/section just like in Gutenberg block?
- Images give 404 after changing default domain
- How to set uploaded image as featured image wordpress
- Create a post from every image in my media gallery
- How to stop WordPress from completely overriding my tags in my templates?
- How to change the value “uploaded to” in the media library (WordPress 4.0)
- How can I change the to for lazyload wp smilies
- Allow users to upload multiple images to their profile
- Making a parent directory writable by the server
- Indicate image sizes for upload by post type
- User uploads image as “Featured Image” but WordPress resizes it?
- Profile image does not upload
- Large uploaded images not resizing?
- How to change Gallery image url in product page ? In function.php?
- Form File Upload Field generates multiple copies of Image Files (different sizes): Is this a WP feature or is this being done by the Plugin
- How to get title of images in post content
- Upload error on localhost (at minimum, not yet tested online)
- How to generate alt attributes with php / filters?
- Unset image sizes before images are uploaded
- Loading and Referencing Images
- unsharp thumbnails after uploading image
- How to delete original image file after upload and resize
- An error has occurred during the upload process in wordpress version 5.3.2
- An error has occurred during the upload process in wordpress 5.3.2
- Import images from old WordPress site into new site
- How to handle a lot of media files in the uploads folder? (+10.000)
- Widget media uploader doesn’t opens after widget save
- Getting the Select and Crop Functionality Using Custom Fields
- Run command to optimize images after they get uploaded to WordPress
- How to modify images during upload
- After I upload a file to library its name converted to dashes
- Reduce Mobile Image upload size (wordpress)
- The most of the images don’t appear, although URLs are correct
- Surround uploaded image link with div
- Only User Upload image Http Error
- Add two images with Sweet Testimonials
- See the all uploaded images of a user as an admin
- Broken Media Library
- Utilise WP_Customize_Image_Control to only show image picker
- 3.5.x Theme Customize: Handling Custom Control Requests
- Import existing image as a single post
- Custom filename when pasting an image from clipboard
- Media Library is not loading on grid view in admin panel
- Best Photoshop-WordPress workflow for editing images without re-upload [closed]
- How to add a link to media file for every image inserted in content?
- What does WordPress media uploader do to image files on upload?
- How to get WordPress to resize images for srcset?
- Uploading media to wordpress API with C# HttpClient