Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* my html markup looks like */
- <input id="upload_image" type="text" size="36" name="upload_image" value="" />
- <button class="upload_image_button" type="button"><?php _e('Upload Image');?></button>
- <br /><span>Enter an URL or upload an image for the banner.</span>
- /*my script looks like */
- jQuery(document).ready(function($) {
- var formfield;
- $('.upload_image_button').click(function() {
- formfield = $(this).prev('input');
- tb_show('', 'media-upload.php?type=image&TB_iframe=true');
- return false;
- });
- window.original_send_to_editor = window.send_to_editor;
- window.send_to_editor = function(html){
- if (formfield) {
- fileurl = $('img',html).attr('src');
- formfield.val(fileurl);
- tb_remove();
- formfield = ''; //reset formfield to null
- } else {
- window.original_send_to_editor(html);
- }
- };
- }); //end doc-ready
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement