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

git-svn-id: http://svn.automattic.com/wordpress/trunk@19424 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-11-23 20:32:21 +00:00
parent f55996cc33
commit d170df731a
3 changed files with 31 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@ -6967,8 +6967,9 @@ div.zerosize {
.press-this #poststuff h2, .press-this #poststuff h2,
.press-this #poststuff h3 { .press-this #poststuff h3 {
font-size: 13px; font-size: 14px;
line-height: 1; line-height: 1;
margin: 10px;
} }
.press-this #tagsdiv-post_tag h3, .press-this #tagsdiv-post_tag h3,
@ -7019,7 +7020,7 @@ h3.tb {
} }
.press-this #extra-fields .actions { .press-this #extra-fields .actions {
margin: -23px -7px 0 0; margin: -25px -7px 0 0;
} }
.press-this .actions li { .press-this .actions li {

View File

@ -139,19 +139,19 @@ if ( !empty($_REQUEST['ajax']) ) {
tb_remove(); tb_remove();
}); });
jQuery('.select').click(function() { jQuery('.select').click(function() {
image_selector(); image_selector(this);
}); });
/* ]]> */ /* ]]> */
</script> </script>
<h3 class="tb"><label for="tb_this_photo_description"><?php _e('Description') ?></label></h3> <h3 class="tb"><label for="tb_this_photo_description"><?php _e('Description') ?></label></h3>
<div class="titlediv"> <div class="titlediv">
<div class="titlewrap"> <div class="titlewrap">
<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);?>"/> <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);?>"/>
</div> </div>
</div> </div>
<p class="centered"> <p class="centered">
<input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="tb_this_photo" /> <input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="tb_this_photo" class="tb_this_photo" />
<a href="#" class="select"> <a href="#" class="select">
<img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" /> <img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" />
</a> </a>
@ -270,8 +270,16 @@ if ( !empty($_REQUEST['ajax']) ) {
return false; return false;
} }
function image_selector() { function image_selector(el) {
var desc = jQuery('#tb_this_photo_description').val() || '', src = jQuery('#tb_this_photo').val() || ''; var desc, src, parent = jQuery(el).closest('#photo-add-url-div');
if ( parent.length ) {
desc = parent.find('input.tb_this_photo_description').val() || '';
src = parent.find('input.tb_this_photo').val() || ''
} else {
desc = jQuery('#tb_this_photo_description').val() || '';
src = jQuery('#tb_this_photo').val() || ''
}
tb_remove(); tb_remove();
pick(src, desc); pick(src, desc);
@ -368,15 +376,24 @@ var photostorage = false;
function setup_photo_actions() { function setup_photo_actions() {
jQuery('.close').click(function() { jQuery('.close').click(function() {
jQuery('#extra-fields').hide(); jQuery('#extra-fields').hide();
jQuery('body').append( jQuery('#photo-add-url-div') );
jQuery('#extra-fields').html(''); jQuery('#extra-fields').html('');
}); });
jQuery('.refresh').click(function() { jQuery('.refresh').click(function() {
photostorage = false; photostorage = false;
jQuery('body').append( jQuery('#photo-add-url-div') );
show('photo'); show('photo');
}); });
jQuery('#photo-add-url').click(function(){ jQuery('#photo-add-url').click(function(){
var form = jQuery('#photo-add-url-div').clone(); var container = jQuery('#img_container');
jQuery('#img_container').empty().append( form.show() );
if ( container.children('#photo-add-url-div:visible').length ) {
container.children('a').show();
jQuery('#photo-add-url-div').hide();
} else {
container.children('a').hide();
container.append( jQuery('#photo-add-url-div').show() );
}
}); });
jQuery('#waiting').hide(); jQuery('#waiting').hide();
jQuery('#extra-fields').show(); jQuery('#extra-fields').show();
@ -625,12 +642,12 @@ var photostorage = false;
<div id="photo-add-url-div" style="display:none;"> <div id="photo-add-url-div" style="display:none;">
<table><tr> <table><tr>
<td><label for="this_photo"><?php _e('URL') ?></label></td> <td><label for="this_photo"><?php _e('URL') ?></label></td>
<td><input type="text" id="this_photo" name="this_photo" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" /></td> <td><input type="text" id="this_photo" name="this_photo" class="tb_this_photo text" onkeypress="if(event.keyCode==13) image_selector(this);" /></td>
</tr><tr> </tr><tr>
<td><label for="this_photo_description"><?php _e('Description') ?></label></td> <td><label for="this_photo_description"><?php _e('Description') ?></label></td>
<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> <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>
</tr><tr> </tr><tr>
<td><input type="button" class="button" onclick="image_selector()" value="<?php esc_attr_e('Insert Image'); ?>" /></td> <td><input type="button" class="button" onclick="image_selector(this)" value="<?php esc_attr_e('Insert Image'); ?>" /></td>
</tr></table> </tr></table>
</div> </div>
<?php <?php