Make WordPress Core


Ignore:
Timestamp:
11/23/2011 08:32:21 PM (14 years ago)
Author:
azaozz
Message:

Fix inserting images from url in Press This, fixes #19341

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/press-this.php

    r19381 r19424  
    140140                });
    141141                jQuery('.select').click(function() {
    142                     image_selector();
     142                    image_selector(this);
    143143                });
    144144                /* ]]> */
     
    147147            <div class="titlediv">
    148148                <div class="titlewrap">
    149                     <input id="tb_this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/>
     149                    <input id="tb_this_photo_description" name="photo_description" class="tb_this_photo_description tbtitle text" onkeypress="if(event.keyCode==13) image_selector(this);" value="<?php echo esc_attr($title);?>"/>
    150150                </div>
    151151            </div>
    152152
    153153            <p class="centered">
    154                 <input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="tb_this_photo" />
     154                <input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="tb_this_photo" class="tb_this_photo" />
    155155                <a href="#" class="select">
    156156                    <img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" />
     
    271271        }
    272272
    273         function image_selector() {
    274             var desc = jQuery('#tb_this_photo_description').val() || '', src = jQuery('#tb_this_photo').val() || '';
     273        function image_selector(el) {
     274            var desc, src, parent = jQuery(el).closest('#photo-add-url-div');
     275
     276            if ( parent.length ) {
     277                desc = parent.find('input.tb_this_photo_description').val() || '';
     278                src = parent.find('input.tb_this_photo').val() || ''
     279            } else {
     280                desc = jQuery('#tb_this_photo_description').val() || '';
     281                src = jQuery('#tb_this_photo').val() || ''
     282            }
    275283
    276284            tb_remove();
     
    369377                    jQuery('.close').click(function() {
    370378                        jQuery('#extra-fields').hide();
     379                        jQuery('body').append( jQuery('#photo-add-url-div') );
    371380                        jQuery('#extra-fields').html('');
    372381                    });
    373382                    jQuery('.refresh').click(function() {
    374383                        photostorage = false;
     384                        jQuery('body').append( jQuery('#photo-add-url-div') );
    375385                        show('photo');
    376386                    });
    377387                    jQuery('#photo-add-url').click(function(){
    378                         var form = jQuery('#photo-add-url-div').clone();
    379                         jQuery('#img_container').empty().append( form.show() );
     388                        var container = jQuery('#img_container');
     389
     390                        if ( container.children('#photo-add-url-div:visible').length ) {
     391                            container.children('a').show();
     392                            jQuery('#photo-add-url-div').hide();
     393                        } else {
     394                            container.children('a').hide();
     395                            container.append( jQuery('#photo-add-url-div').show() );
     396                        }
    380397                    });
    381398                    jQuery('#waiting').hide();
     
    626643    <table><tr>
    627644    <td><label for="this_photo"><?php _e('URL') ?></label></td>
    628     <td><input type="text" id="this_photo" name="this_photo" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" /></td>
     645    <td><input type="text" id="this_photo" name="this_photo" class="tb_this_photo text" onkeypress="if(event.keyCode==13) image_selector(this);" /></td>
    629646    </tr><tr>
    630647    <td><label for="this_photo_description"><?php _e('Description') ?></label></td>
    631     <td><input type="text" id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/></td>
     648    <td><input type="text" id="this_photo_description" name="photo_description" class="tb_this_photo_description text" onkeypress="if(event.keyCode==13) image_selector(this);" value="<?php echo esc_attr($title);?>"/></td>
    632649    </tr><tr>
    633     <td><input type="button" class="button" onclick="image_selector()" value="<?php esc_attr_e('Insert Image'); ?>" /></td>
     650    <td><input type="button" class="button" onclick="image_selector(this)" value="<?php esc_attr_e('Insert Image'); ?>" /></td>
    634651    </tr></table>
    635652</div>
Note: See TracChangeset for help on using the changeset viewer.