Changeset 898362
- Timestamp:
- 04/19/2014 10:48:50 PM (12 years ago)
- Location:
- simple-upload-widget/trunk
- Files:
-
- 3 edited
-
readme.txt (modified) (1 diff)
-
script.js (modified) (1 diff)
-
simpleUploadWidget.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-upload-widget/trunk/readme.txt
r828084 r898362 2 2 Contributors: fuhton 3 3 Tags: widget, theme, file, template, appearance, image, upload, simple, single 4 Tested up to: 3. 84 Tested up to: 3.9 5 5 License: GPLv2 or later 6 6 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
simple-upload-widget/trunk/script.js
r827684 r898362 1 var image_field; 2 jQuery(function($){ 3 jQuery(document).on('click', 'input.select-img', function(evt){ 4 image_field = $(this).siblings('.img'); 5 tb_show('', 'media-upload.php?type=image&TB_iframe=true'); 6 return false; 1 /* 2 * Description: 3 * Media uploader via WP 3.5 4 * 5 * @method void 6 * @param void 7 * @return false 8 */ 9 (function($) { 10 $(function() { 11 12 var _custom_media = true, 13 _orig_send_attachment = wp.media.editor.send.attachment; 14 15 $(document).on('click', '.suw-button-select.button', function () { 16 var send_attachment_bkp = wp.media.editor.send.attachment, 17 input = $(this).prev('.suw-input-field'); 18 _custom_media = true; 19 wp.media.editor.send.attachment = function(props, attachment){ 20 if ( _custom_media ) { 21 input.val(attachment.url); 22 } else { 23 return _orig_send_attachment.apply( this, [props, attachment] ); 24 }; 25 } 26 wp.media.editor.open( $(this) ); 27 return false; 28 }); 29 7 30 }); 8 window.send_to_editor = function(html) { 9 imgurl = $('img', html).attr('src'); 10 image_field.val(imgurl); 11 tb_remove(); 12 } 13 }); 31 })(jQuery); -
simple-upload-widget/trunk/simpleUploadWidget.php
r828084 r898362 5 5 Author: Nick Smith 6 6 Author URI: http://iliketheideaof.us 7 Version: 0.1. 17 Version: 0.1.3 8 8 */ 9 9 … … 25 25 public function widget( $args, $instance ) 26 26 { 27 $image_instance = $instance[' image_uri'];27 $image_instance = $instance['suw_image_loca']; 28 28 29 29 // basic output … … 35 35 ?> 36 36 <p> 37 <label for="<?php echo $this->get_field_id(' image_uri'); ?>">Image</label><br />38 <input type="text" class=" img" name="<?php echo $this->get_field_name('image_uri'); ?>" id="<?php echo $this->get_field_id('image_uri'); ?>" value="<?php echo $instance['image_uri']; ?>" />39 <input type="button" class="s elect-img" value="Select Image" />37 <label for="<?php echo $this->get_field_id('suw_image_loca'); ?>">Image</label><br /> 38 <input type="text" class="suw-input-field <?php echo $this->get_field_name('suw_image_loca'); ?>" name="<?php echo $this->get_field_name('suw_image_loca'); ?>" id="<?php echo $this->get_field_id('suw_image_loca'); ?>" value="<?php echo $instance['suw_image_loca']; ?>" /> 39 <input type="button" class="suw-button-select button button-primary <?php echo $this->get_field_name('suw_image_loca'); ?>" id="<?php echo $this->get_field_name('suw_image_loca'); ?>" value="Select Image" /> 40 40 </p> 41 41 <?php … … 51 51 function suw_enqueue() 52 52 { 53 wp_enqueue_style('thickbox'); 54 wp_enqueue_script('media-upload'); 55 wp_enqueue_script('thickbox'); 53 wp_enqueue_media(); 56 54 wp_enqueue_script('hrw', '/wp-content/plugins/simple-upload-widget/script.js', null, null, true); 57 55 }
Note: See TracChangeset
for help on using the changeset viewer.