Created
November 28, 2012 04:48
-
-
Save caratage/4159071 to your computer and use it in GitHub Desktop.
Send to editor - jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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&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