Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(document).ready(function() {
- jQuery('.upload_image_button').click(function() {
- targetfield = jQuery(this).prev('.upload_image'); // locates the textbox where the url is to be stored
- targetimg = jQuery(this).prev('.preview_image'); // locates the img element where to preview the image before save
- tb_show('Choose Image', 'media-upload.php?type=image&TB_iframe=true'); // shows the wordpress media uploader
- old_ste = window.send_to_editor; // save current send_to_editor
- return false;
- });
- window.send_to_editor = function(html) {
- imgurl = jQuery('img',html).attr('src'); // gets the image url from media uploader
- jQuery(targetfield).val(imgurl); // puts the image url in the textbox, successfully
- jQuery(targetimg).attr('src',imgurl); // changes the source of the preview image element, unsuccessfully
- tb_remove(); // closes the wordpress media uploader
- window.send_to_editor = old_ste; // restores previous send_to_editor
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement