Plugin Directory

Changeset 898362


Ignore:
Timestamp:
04/19/2014 10:48:50 PM (12 years ago)
Author:
fuhton
Message:

update to new media uploader and better javascript

Location:
simple-upload-widget/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • simple-upload-widget/trunk/readme.txt

    r828084 r898362  
    22Contributors: fuhton
    33Tags: widget, theme, file, template, appearance, image, upload, simple, single
    4 Tested up to: 3.8
     4Tested up to: 3.9
    55License: GPLv2 or later
    66License 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
    730    });
    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  
    55Author: Nick Smith
    66Author URI: http://iliketheideaof.us
    7 Version: 0.1.1
     7Version: 0.1.3
    88*/
    99
     
    2525    public function widget( $args, $instance )
    2626    {
    27         $image_instance = $instance['image_uri'];
     27        $image_instance = $instance['suw_image_loca'];
    2828
    2929        // basic output
     
    3535      ?>
    3636     <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="select-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" />
    4040     </p>
    4141     <?php
     
    5151function suw_enqueue()
    5252{
    53     wp_enqueue_style('thickbox');
    54     wp_enqueue_script('media-upload');
    55     wp_enqueue_script('thickbox');
     53    wp_enqueue_media();
    5654    wp_enqueue_script('hrw', '/wp-content/plugins/simple-upload-widget/script.js', null, null, true);
    5755}
Note: See TracChangeset for help on using the changeset viewer.