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
- 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
- Hide old attachments from wp media library
- Image Upload “exceeds the maximum upload size for this site”, but php.ini is correct
- Failed media upload: “The uploaded file was only partially uploaded.”
- Create Image Uploader for Widget
- Admin Media grid view images won’t load
- Debugging upload problem: What part of WP does actual image-resizing?
- How to resize image on client-side before upload?
- Specified file failed upload test. wp_upload_handle
- Accessing a random image via ajax
- Is it unsafe to put php in the /wp-content/uploads directory?
- Restrict WordPress File Type Uploads by User Type
- Modify Maximum upload file size text
- How to import 55k images (uploaded via FTP) into WordPress Media libary? [closed]
- Upload a json file in php [closed]
- Custom image upload
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- Get most recent media upload
- Upload Image in a WordPress page using PHP
- How to get media objects
- WordPress (3.9.1) MultiSite Permissions. Is chown the answer?
- How do the pros code up a WordPress theme? Locally? Through FTP?
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false
- how to retrieve uploaded url of zip files
- Why is $_REQUEST an empty array in admin-ajax.php?
- wordpress media library new uploads don’t write to database
- How to upload a file to a folder named after the user_id via plugin
- add custom link to wordpress media gallery modal
- Upload multiple images to a Woocomerce product
- Upload file could not be moved to wp-content/uploads
- NGINX rewrite rules for multisite
- Change WordPress Upload Folder using wp handle upload
- How do I Import / Upload Files with jQuery AJAX?
- WordPress automatically adds links to uploaded images
- WordPress function when file is uploaded, deleted or edited
- 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()
- WordPress İmages Upload & Delete Error
- How to Make Thumbnail of Post Stay Animated
- 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
- 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
- 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
- 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
- get_post_meta returns on side but it doesn’t return on bottom of admin page