WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I really like the way SE uploads an image from a URL (I'm sure many do!). I've been searching, but can't find, is there a plugin or a method similar to this available for WordPress?

I know an image can be uploaded and crunched directly from a URL by entering the image URL into the File Name box after you click Upload/Insert Media >> From Computer >> Choose File

enter image description here

This is a great feature, but not very widely known (I actually just discovered it). I would like something a little more like SE, where there is an option that let the user know to add the image URL.

How can I go about adding simply the upload file field to a new tab in the media uploader?

Here is a tutorial for How to add a new tab in Media Upload page in wordpress, but I want to add only some text and the file upload field to that tab. Any ideas? I couldn't find anything in the WordPress Codex that deals with this feature or the file upload field directly.


share|improve this question
Feature requests belong on trac.wordpress.org. – Wyck Apr 24 '12 at 23:10
Not a feature request. The feature is already built in. – Travis Pflanz Apr 24 '12 at 23:31

you can write a php script, or make your own plugin of this code here, i used it in one of my projects where i had to import a large number of images.

first, get the image, and store it in your upload-directory:

$uploaddir = wp_upload_dir();
$uploadfile = $uploaddir['path'] . '/' . $filename;

$contents= file_get_contents('http://mydomain.com/folder/image.jpg');
$savefile = fopen($uploadfile, 'w');
fwrite($savefile, $contents);

after that, we can insert the image into the media library:

$wp_filetype = wp_check_filetype(basename($filename), null );

$attachment = array(
    'post_mime_type' => $wp_filetype['type'],
    'post_title' => $filename,
    'post_content' => '',
    'post_status' => 'inherit'

$attach_id = wp_insert_attachment( $attachment, $uploadfile );

$imagenew = get_post( $attach_id );
$fullsizepath = get_attached_file( $imagenew->ID );
$attach_data = wp_generate_attachment_metadata( $attach_id, $fullsizepath );
wp_update_attachment_metadata( $attach_id, $attach_data );

and voila - here we go. you can also set various other parameters in the attachment array. if you got an array of urls or something like that, you can run the script in a loop - but be aware that the image functions take up a lot of time and memory to execute.

share|improve this answer
oh, i'm sorry, i didn't see the image at first. maybe i will write a small plugin doing exactly this. i hope you can get along with my script so far - i will keep you posted on plugin news. – fischi Apr 30 '12 at 17:07
I think I added the image just as you posted. I will take a more in-depth look when I get back from lunch. Thanks for your assistance! Always appreciated. – Travis Pflanz Apr 30 '12 at 17:53
up vote 4 down vote accepted

WordPress Plugin Directory - Grab & Save

This plugin allow you to grab image from remote url and save into your own wordpress media library. By doing so, you never worried if the remote image was removed by its owner. This also save you steps to download the image to local computer and upload again to your own wordpress.

After grabbing the image, wordpress will prompt you either to "insert into post" or "change attributes" just like after you upload an image.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.