There’re 2 things you should consider:
-
change
send_to_editor
insideclick
callback. This will change this function only when needed, e.g. when uploader is shown. This also prevent unwanted things with global variables. -
You should always backup the
send_to_editor
.
Here’s my sample code (not tested):
jQuery(document).ready(function($) {
$('#upload_image_button_main').click(function() {
var backup = window.send_to_editor;
window.send_to_editor = function(html) {
imgurl = $('img', html).attr('src');
jQuery('#_my_meta_upload_image_main').val(imgurl);
tb_remove();
};
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
window.send_to_editor = backup;
return false;
});
});
Related Posts:
- Add “upload media” button in meta box field
- Add a Meta Box for uploading a SECOND Featured Image?
- Attach Files Metabox
- Adding uploaded images to editor from metabox instead of default popup uploader
- I need a Simple image uploader with a simple screen. WP default has too many options.
- Customize WordPress Media Upload and New Media Manager Menu in add post Metabox
- WPAlchemy MediaAccess inserting media link in WP Editor instead of custom field in metabox [closed]
- How to add meta box for image upload using WordPress media uploader?
- Insert media button will always add into the same tinyMCE editor
- Generating image sizes when uploading through wp.media
- Saving an upload media meta box field
- Remove the Featured Image Meta Box
- Remove the Yoast SEO Post Metabox [closed]
- Sample code for validating custom metabox?
- How to add a class to meta box
- Use meta box drag and drop to order items independently
- inside a metabox
- Add Meta box Befoure Post Title
- Editing the Default Links like “Site Admin” in the Sidebar Meta Section?
- Editing Screen: Make Update or Publish Button Follow The Page
- Custom “Publish” / “Update” button &
- Why can’t I hook into save_posts after admin_init?
- Meta Boxes in Front End Post Submission Form
- Custom meta box shown when template is chosen [duplicate]
- Modifying the main editor priority
- How to make a meta box field a requirement
- Choosing a default page tempate (Classic => Gutenberg)
- How to remove the RichText Meta Box
- Add character count to custom metabox
- Update caption for metabox gallery images
- Metabox of one post influence setting on other
- Display Single Attachment Image file size, uploaded date, resolution, file-name etc in Sidebar
- datetime_timestamp shows numbers only? need in date and time
- Custom Metabox with Ajax in Edit Post – Stuck
- Post.php – Conditional statements for new post and edit post
- How to generate a featured image from a video embeded in a metabox
- I’m confused about URL sanitization in meta boxes
- unable to save post meta on single field with multiple selects
- Meta box io oembed returns list not array
- Hide meta box based on post format
- How to verify meta box is registered in Unit Testing?
- Add a custom field to top attribute in WooCommerce
- wp_editor in metabox not working
- WPAlchemy: How to output values?
- Select box saves but doesn’t update value in admin
- get $post (object,parts/values) in meta-box
- retrieve meta key when checkbox is used
- Add Meta Box not showing on New Post – Custom meta box not showing
- How to display a custom post type’s media library inline on meta box
- Modules with meta box implementations
- Remove meta box for specific page
- How To Add Custom Meta PDF Upload Box to WooCommerce Products (and post link on frontend)
- Using WYSIWYG In custom meta boxes
- Visual/Text tabs in wp editor Not Showing
- save_post action to include wp_insert_post_data filter, gathering meta field info & prevent infinite loop
- Adding meta box without add_meta_box – is this bad?
- Upload Button in meta box not opening library
- saving data entered into a Metabox into an array? for use with for/each output.
- Cusotm MetaBox content not getting saved
- How to get the meta box name and value
- Checking if $_FILE isset for an array of file upload metaboxes
- My custom write panels won’t save data. What am I missing?
- How to position user meta data field
- How to create a button click counter meta box?
- Display Content if Meta Checkbox is checked?
- meta box & callback function
- $_GET & $post_ID
- get_post_meta as a list for drop down search filter
- add_post_meta | update_post_meta | Via the frontend
- Use meta boxes inside an archive page template for Woocommerce
- Why do Metabox use Nonces?
- multi custom fields and taxonomy search
- Migrating from metaboxes to wp_editor()
- conditionally echo in meta box data loop
- Front end post and upload file, image for users without plugin
- Meta Box multi checkbox in template
- Dynamic number of fields in a meta box
- How to make a metabox that contains link categories?
- how to log in to WP if the “Log in” link under Meta is missing
- Echo 2 values from one key in Array with get_post_custom
- meta box pop up upload button wont work
- Meta Box – Javascript Datatable
- Metabox on a custom page – How to include the appropriate default scripts and styles?
- custom metabox nonce verification fails
- Extensible add_meta_box with apply filters
- Why is the text displaying, but not the textarea field itself?
- Meta box checkbox won’t save
- Set post title to same value as a tow meta box
- add_post_meta Adds post meta but the value is blank
- Best practices for meta box placement?
- Echo order box (in pages)
- WP Alchemy – stripping my paragraph tags from textarea metaboxes
- Meta boxes not showing on custom post type. Blank page?
- Tags meta box don’t show when creating a new post type
- dynamically get post attachment while editing
- Remove Title, Editor and Meta Box Support Based on Post Formats
- Custom select box meta field
- Metadata in loops
- Conditonally check if Custom Meta Box has input
- Metaboxes – why they don’t render php in expected manner?