Two options:
-
Hook into
'wp_handle_upload'
, a filter provided by the functionwp_handle_upload()
inwp-admin/includes/file.php
:apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ), 'upload' )
Replace the new file URI with your remote URI.
-
The function
wp_insert_attachment()
inwp-includes/post.php
offers two actions:do_action('edit_attachment', $post_ID); do_action('add_attachment', $post_ID);
You can get the attachment data by
$post_ID
and change any value here.
Related Posts:
- How can I add an image upload field directly to a custom write panel?
- Checking if a file is already in the Media Library
- Standard location for plugin to save/cache files?
- Saving data-URI to media library
- Can I use the wp media uploader for my own plugin?
- Change Media Uploader default directory
- Changing upload directory for plugin uploads only
- Why are two functions over-riding each other?
- WordPress Media mime type filter problem 4.0
- Using the component outside the editor. select(‘core’) is null
- Proper way to hook wp_get_attachment_url
- Getting Details Of Uploaded Image
- Sharing a common set of image files for media library, across all sites within multisite
- Uploading images from a custom page using blueimp uploader?
- Hook to get image filename when it is uploaded
- How to send email in wordpress with more than one attachments
- Using the default wordpress uploader inside plugin
- Files automatically added
- What filter should I use to insert a button inside on Media>Add New
- Changing upload dir in a plugin regardless of post type
- How to replicate Media Library “Add New” on Plugin Settings Page
- Plugin writing: access file that was just uploaded
- Custom delete option button in plugin settings
- How to enable sorting in custom media uploader in plugin
- Create a new post using rest api and save featured image using an external image url
- Why is the temporary upload always 4.1K
- Upload multiple images and insert them into custom html code
- wp_editor add media button not working
- WordPress Specified file failed upload test
- How to create a digital product download link that can’t be used twice?
- How to submit/upload data to database and in specific folder?
- Cleaning a filename after image sideloading a url that contains `%20`
- Get audio metadata on file upload
- How to move an image in a plugin to the upload directory and make it as a media of wordpress?
- Why doesn’t update_post_meta work for certain strings?
- wp.media Uncaught TypeError: Cannot read properties of undefined (reading ‘state’)
- Insert and read media from the WordPress library and call in the plugin
- Trying to rename a file upload as the hash of file content on wordpress
- Home page is not loading, where in other pages are displaying on the site
- WordPress5.2.3: Better File Download Plugin validation issue
- WordPress discards PNG file when uploading plugin file
- Hook for validating and rejecting frontend image upload
- Changed media upload path for plugin, but generates error & shows wrong url
- How to destroy or dispose wordpress uploder/manager?
- Displaying $_FILES data (simlar to $_POST)
- Changing upload directory for plugin uploads only
- How do you filter get_media_items by mime type in a custom media upload tab?
- Is it possible to convert various image types from remote URLs to WebP and then serve them immediately?
- upload script in plugin development [duplicate]
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- Upload to a specific media folder created by FileBird Lite
- Load images from CDN and custom features to “Add Media” dialogue
- upload image to wordpress media library failed for custom post type
- How do I add CSS options to my plugin without using inline styles?
- How do I create links at the top of WP_List_table?
- Why Does get_posts() Return an Empty Set?
- Retrieving custom fields with $wpdb->get_results
- Current class on admin menu using add_submenu_page()
- Add new user and add meta at once
- Odd behaviour with submenu link creation
- Problems with removing admin bar
- Handling form request from plugin file
- Timeout on Admin-Ajax?
- Finding the paragraphs in content
- When I deactive WooCommerce Plugin, I want to take a action in My plugin
- Create a custom display order in the main menu
- Override the default Add/Edit site forms of the Network Panel in custom plugin
- add more custom post types and custom role to the code
- A better way to include localized labels in WordPress plugins
- plugin settings – uploading multiple files with a single button
- Getting term_id for newly created or edited term
- How to insert text at the current cursor position in Gutenberg?
- How to fix this URL error in WordPress ” data-wplink-url-error=”true”>
- Remove unwanted elements for a wp_nav_menu
- Edit Images From the Front End without Access to WP Admin
- How to remove or add submenu item on plugin activate or deactive
- Difference between wp_salt schemes
- How can I replace the search results displayed by WordPress?
- I18n not working in plugin
- making a plugin that moves other plugins wp_head actions to wp_footer
- How to redirect to login page when user not loggedin on a particular page
- Non editable custom taxonomy
- How to resize WordPress images on upload to specific height and width without cropping it
- Checking for existing title in custom db query not working
- How to add a new taxonomy link to the admin menu
- Many Single Sites, One Plugin directory – adjust plugins_url()
- insufficient permissions; coding an action for plugin governed by custom capability
- My plugin creates custom widgets, How can I programatically add them to existing sidebar widget areas?
- How to know if current plugin is going to be used while rendering the page?
- functions won’t fire after I converted my code from procedural code to OOP
- CPT UI and custom database table
- Updating a WP Plugin SVN not showing on WordPress Website or Zip
- How to add chunk of php, html, and sql code to variable an append to $content
- edit-tags.php in plugin admin menu hides when is the active page
- Best way to handle a form post in plugin
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- Remove text from confirmation message
- Can I use an array to create multiple tables?
- How to add extra EXIF data when images are uploaded?
- How to boost WP custom post REST API GET queries by custom taxonomies