Skip to content

Instantly share code, notes, and snippets.

@caratage
Created November 28, 2012 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caratage/4159071 to your computer and use it in GitHub Desktop.
Save caratage/4159071 to your computer and use it in GitHub Desktop.
Send to editor - jQuery
<div class="upload_field"
<input type="text" name="upload_one" id="upload_one" class="upload" value="" />
<input type="button" class="upload-button" value="Upload Image" />
</div>
<div class="upload_field"
<input type="text" name="upload_two" id="upload_two" class="upload" value="" />
<input type="button" class="upload-button" value="Upload Image" />
</div>
var uploadID = ''; /*setup the var*/
jQuery('.upload-button').click(function() {
uploadID = jQuery(this).prev('input'); /*grab the specific input*/
formfield = jQuery('.upload').attr('name');
tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
return false;
});
window.send_to_editor = function(html) {
imgurl = jQuery('img',html).attr('src');
uploadID.val(imgurl); /*assign the value to the input*/
tb_remove();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment