0

I was wondering if there is a way to get the URL address to prepopulate with my web address so I don't have to type it in every time I want to insert an image.

Example.

Click on the upload/insert "add media" button --> click "from URL" and instead of having a blank box, I would like it to prepopulate with:

http://mysite.com/images/

this way the only thing I would have to type in is: nameofimage.jpg

1
  • just wondering... did my answer help? Apr 3, 2012 at 19:40

1 Answer 1

1

You can apply a filter to the output of the media insert url form using the filter named wp_media_insert_url_form:

add_filter('wp_media_insert_url_form', 'ex46632_media_insert_url_form');
function ex46632_media_insert_url_form($html) {
    $html = str_replace('<input id="src" name="src" value=""', '<input id="src" name="src" value="http://mysite.com/images/"', $html);
    return $html;
}

Something like this could be added to your theme's functions.php file. This is untested code that is just as an example of direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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