You can upload your images to your host, and then use media_sideload_image()
to upload each file. Let’s assume you upload all of your images to a folder named wpse
, in the root of your WordPress installation:
// Set the directory
$dir = ABSPATH .'/wpse';
// Define the file type
$images = glob($directory . "*.jpg");
// Run a loop and upload every file to media library
foreach($images as $image) {
// Upload a single image
media_sideload_image($image,'SOME POST ID HERE');
}
Images must be attached to a post, but you can detach them afterward.
Related Posts:
- How to register images uploaded via FTP in media library?
- WordPress media upload “HTTP error”
- How to upload a media file via FTP and then create an attachment post with it?
- Adding a querystring to an image URL when clicking ‘insert into post’?
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- zip unzip attachments in wordpress
- Change image data durgin upload
- Upload images from one server to an other in wordpress
- Renaming “Expand Details” within “Add Media”
- Edit Image/Image Details – Replace button missing
- Changing upload directory temporarily
- How to save WordPress post and attachment images from front end using media library?
- How to change upload directory in wp_handle_upload
- Uploading media with the REST API
- Remove “Insert from URL” link in Media upload – WP 3.5
- Decrease file size upload in Media
- Adding a custom image upload size and making it selected by default?
- Hide custom image sizes from media library
- Change the filename format of saved featured images
- Hide old attachments from wp media library
- How do I get around “Sorry, this file type is not permitted for security reasons”?
- Change WordPress Upload Folder using wp handle upload
- How do I Import / Upload Files with jQuery AJAX?
- Redirect to another page using contact form 7? [closed]
- WordPress automatically adds links to uploaded images
- WordPress function when file is uploaded, deleted or edited
- Download images from media library to computer in BULK?
- Can I get an email notification when media is uploaded to the media library?
- Moving wordpress site from localhost to live server using GoDaddy cPanel
- Blob file download problem
- How to remap one of the TinyMCE Advanced Editor button to open the wordpress media library?
- Upload multiple files in randomly generated folder using wp_upload_bits
- Can’t upload CSV file to plugin directory using custom upload form in admin panel
- WordPress upload file size error even after raising php limits
- Get uploaded image and attach it to the new post
- Get featured image with custom size outside WordPress
- Why is my max_upload_filesize being limited to 2M? [duplicate]
- Images Uploaded saving onto older/previous year folders
- How do I increase the upload size only when editing special pages?
- Convert canvas to image and upload image to server
- How to get the filename from file system and create a download link?
- Get URL of Featured Image After wp_insert_post()
- Custom upload folder
- WordPress İmages Upload & Delete Error
- Allow user to Upload image and manipulate it on the frontend
- custom plugin with upload files does not work
- How to Make Thumbnail of Post Stay Animated
- Front end file upload returning wrong attachment url
- Convert all uploaded PNG files to PNG-8 format
- How to decrease the max file upload size without using php.ini or htaccess?
- Help with accessing wp-admin page and resolving error messages
- Some problems in custom widget
- Checking page before applying image restrictions while uploading
- Hook on file upload
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- I can’t set image ad fatured programatically
- How can I update WordPress plugins or WordPress itself in all server?
- async upload not working when not logged
- WordPress loading all local images from specific directory?
- Trying to generate a CSS file in wordpress uploads folder
- The style.php file inside theme-engine folder has other content on FTP
- AJAX and custom pages
- overwrite wordpress gallery with custom gallery shortcode
- Maximum file Upload
- Using custom php to connect to database blocks wp from accessing galery pictures
- Sudden Upload HTTP errors, PHP uploads and memory limits are already to high to my taste. Anything else?
- Change upload URL by mime type
- Right path for renaming a file in uploads folder
- How to handle a lot of media files in the uploads folder? (+10.000)
- I want url from a file in media using title file
- WordPress file upload
- Crop an image after upload on custom account page
- media_handle_upload fails with gravity form submitted image
- Restrict File Type Uploads by User on Wordress via functions.php
- wp_delete_attachment not working with multiple values
- Save the outputted image into the Media Library, with a different filename and extension
- 403 (Forbidden) delete file image in themer folder
- File path for attachments outside of wp-content/uploads
- Is custom behaviour possible when asynchronously uploading?
- How to resize an image server-side before upload?
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- Name Input from widget displays Sidebar name instead of saved data
- show/hide attachments
- Can’t upload files
- File Upload with Server in safe_mode
- Correct Syntax for uploading files to custom directory in WordPress
- How to automatically convert images to WebP on WordPress?
- Generate and upload screenshot as featured image for user-submitted post
- Pull latest Youtube Video from json url and make new post
- WordPress directories not writable after PHP version upgrade
- Many images in wp-content/uploads folder that are not in Media Library
- I can’t log into my website , it says “Error: Cookies are blocked due to unexpected output”
- Upload multiple files via ajax from an HTML file input
- get_post_meta returns on side but it doesn’t return on bottom of admin page
- “Unexpected response from server” error when trying to upload any .mp4 file over 100MB
- Get a list of folders inside uploads directory
- How can we upload custom page files?
- Restricting Image Upload Sizes using ‘wp_handle_upload_prefilter’ – Stuck media progress bar when Featured Image?
- Options for using custom PHP in a wordpress site? No FTP access
- Unable to upload media to WordPress