problem with media library custom widget
-
Hi
As part as a widget im creating i need the admin to upload an image via the widgets panel
I have the following code under a new classfunction form($instance) { $instance = wp_parse_args( (array) $instance, array( 'qrimage'=> ''); $qrimage=$instance['qrimage']; <label for="<?php echo $this->get_field_id('qrimage'); ?>">Upload QR Image: <input class="widefat" id="<?php echo $this->get_field_id('qrimage'); ?>" name="<?php echo $this->get_field_id('qrimage'); ?>" type="text" value='<?php echo attribute_escape($qrimage); ?>' /> Upload Image <label for="uploadi<?php echo $this->get_field_id('qrimage'); ?>"> <input class="uploadi<?php echo $this->get_field_id('qrimage'); ?>" name="uploadi<?php echo $this->get_field_id('qrimage'); ?>" id="uploadi<?php echo $this->get_field_id('qrimage'); ?>" vlue="Upload Image" type="button" /> </label> <script type="text/javascript"> var formfield = ''; var imgurl =''; jQuery(document).ready(function() { jQuery('.uploadi<?php echo $this->get_field_id('qrimage'); ?>').click(function() { formfield = jQuery('#<?php echo $this->get_field_id('qrimage'); ?>').attr('name'); tb_show('', 'media-upload.php?type=image&&TB_iframe=1'); return false; }); // send url back to plugin editor window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); jQuery('#<?php echo $this->get_field_id('qrimage'); ?>').val(imgurl); tb_remove(); } }); </script>
thing is… if i have 1 instance of the widget on the widgets panel , everything works fine.
Once i add another instance, everything’s working except the option to save the image…
The text field gets the link but on save it just disappears
Any thoughts why ?
Thanks
- The topic ‘problem with media library custom widget’ is closed to new replies.