You can use media_sideload_image()
which will take a link to a file and upload it to the media library. You do need to pass it some kind of @Sumit points out in the comments you could pass $post_id
NULL
into the $post_id
field.
media_sideload_image(
$file_url,
$post_id,
$image_desc,
$return
);
If you need the uploaded image ID, take a look Tom J. Nowells answer using hooks
Related Posts:
- Choices for thumbnail image in a Facebook Link post
- Retrieving Default Image All Url Profile Picture from Facebook Graph API [closed]
- Official Facebook Connect button as PNG
- Use Device Login on Smart TV / Console
- Invisible characters – ASCII
- When do I need a fb:app_id or fb:admins?
- When do I need a fb:app_id or fb:admins?
- Warning: Each child in an array or iterator should have a unique “key” prop. Check the render method of `ListView`
- Warning: Each child in an array or iterator should have a unique “key” prop. Check the render method of `ListView`
- og:url is driving me crazy?
- Face recognition via facebook API
- FB is not defined javascript
- What are App Domains in Facebook Apps?
- How can I add an image upload field directly to a custom write panel?
- Image Upload from URL
- How to generate thumbnails when needed only?
- No Thumbnails Generated
- How to Require a Minimum Image Dimension for Uploading?
- How does WP media uploader create the 3 different sized images, and how can I duplicate it
- How can I control the Facebook like image? [closed]
- Upload images to remote server
- How to disable generation of default image sizes for some custom post types?
- Reject upload of wrong-sized images using the Media Uploader
- Each custom image size in custom upload directory?
- How to delete resized (cropped) image uploads and prevent future resizing?
- Download an image from a webpage to the default uploads folder
- After Moving a Site to Another Domain, All Images Are Lost
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- Allow contributor role to upload images and not edit already published articles
- Create image formats with different qualities when uploading
- Is there a hook which fires after all thumbnails are generated?
- Which filters or actions to use after a media upload and delete?
- How can I auto-add my posts to my site’s Facebook fan page?
- Disable image attachment links
- Limit image resolution on upload
- Rename files on upload
- How to insert images into posts without using Add Media dialog
- Using Images in WordPress – Best Practices
- Media Upload Folder – how to manage
- Adding a custom image upload size and making it selected by default?
- PNG with transparent background turns black when uploaded and resized
- Change the filename format of saved featured images
- How to add image uploader to a custom widget?
- Automatically Facebook Debug Posts on Publish [closed]
- How to upload image with simple form?
- Prevent large image uploads
- Modifying an uploaded image with ‘wp_get_image_editor’ and ‘wp_handle_upload_prefilter’
- Settings in ‘Media > Settings’ is ignored when inserting images
- Upload multiple images in a custom metabox
- If your blog was an app on Facebook
- There’s a way to scale media (images) at 50%?
- How to register images uploaded via FTP in media library?
- hook into completed image upload filter
- Saving the pre-sanitized filename of an attachment as the Title or Caption
- Prevent image upload unless exact size
- Using Image insert control in code
- getting uploaded SVG dimensions on front-end
- Adding upload button in metabox
- Use Media upload in custom widget on wordpress 3.5
- Way to force media uploader use custom image size
- How to make WordPress use protocol indepentent upload files?
- Automating a Daily Picture Blog?
- Create Image Uploader for Widget
- Using file_exists to check file in Uploads
- How to prevent upload of a multiple sizes of images
- How can I prevent uploading bmp image?
- How to copy and paste a picture found on the web to wordpress easily
- Set Custom Post feature image as og:image
- Get FaceBook Friend Count [closed]
- Disable resizing of gif when uploaded
- Impose a Maximum Limit on Image height and width upload size
- Force wordpress to see uploads folder media
- Extend WP Customizer to make multiple image selection possible
- Facebook OAuth, WP_Http::request() vs wp_remote_request()
- Images uploading to wrong folder
- Get attachment ID of author_meta image – Attachment Metadata
- Replace all of post’s image URLs with upload directory URLs
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Convert uploaded PNG to JPEG automatically
- Rename image uploads with width in filename
- add_image_size creating lots of images (of various sizes)
- How can I add the “Use as featured image” to a custom metabox?
- Image resize with image url
- How can you upload an image from within a settings page?
- How do i upload an image and return the image id?
- Alter media caption/description conflict in WordPress?
- Debugging upload problem: What part of WP does actual image-resizing?
- Restrict the number of images to upload per post
- Automatically wrap post image in div
- WordPress function: limit size, only jpg, jpeg, limit of uploaded files per account
- Extract image src from a post and send it to an external form
- How to increase media image scale limit?
- Removing Image Sizes for Custom Post Type
- Frontend image uploading from edit profile page. (goldenapples)
- How to resize image on client-side before upload?
- upload featured image from front end using wordpress add media button
- resize images not crop
- W3 Cache plugin and Facebook sharing [closed]
- Image size filtering in Media uploader according to custom post type
- How to upload image without post ID using the new media uploader?