Permalink
Browse files

Merge pull request #157 from humanmade/wp-33-fixes

Fixes for Insert Media buttons
  • Loading branch information...
2 parents 38e90da + ea96e47 commit a6f0361e332b2645c6ac1975d5b688c180277eb5 @hunk committed Jan 11, 2012
Showing with 14 additions and 0 deletions.
  1. +8 −0 RCCWP_WritePostPage.php
  2. +6 −0 js/custom_fields/media_image.js
View
@@ -1083,6 +1083,14 @@ function MultilineTextboxInterface($customField, $inputName, $groupCounter, $fie
$pre_text='';
} ?>
<div class="mul_mf">
+
+ <div style="display: none" id="wp-<?php echo $idField ?>-media-buttons">
+ <?php
+ // WP 3.3 changed here, so you need the media buttons on the editor for the tinyMCE plugin to work
+ require_once( ABSPATH . 'wp-admin/includes/media.php' ) ?>
+ <?php media_buttons( $idField ) ?>
+ </div>
+
<textarea <?php if ($customField->required_field) echo 'validate="required:true"'; ?> class="<?php echo $requiredClass;?> <?php echo $classEditor; ?> <?php echo $pre_text ?>" tabindex="3" id="<?php echo $idField; ?>" name="<?php echo $inputName?>" rows="<?php echo $inputHeight?>" cols="<?php echo $inputWidth?>"<?php echo $maxlength?>><?php echo $value?></textarea>
<?php
if( isset( $customField->properties['strict-max-length'] ) && $customField->properties['strict-max-length'] == 1 ) {
@@ -18,6 +18,12 @@ jQuery(document).ready(function(){
jQuery(".mce_add_image , .mce_add_video , .mce_add_audio , .mce_add_media").live('click',function(){
window.mf_field_id = '';
+ var a = this;
+ // When a mce button is clicked, we have to hotswap the activeEditor instance, else the image will be inserted into the wrong tinyMCE box (current editor)
+ setTimeout( function() {
+ tinyMCE.activeEditor = tinyMCE.EditorManager.getInstanceById( a.id.replace('_add_media', '') );
+ wpActiveEditor = a.id.replace('_add_media', '');
+ }, 500 );
});
});

0 comments on commit a6f0361

Please sign in to comment.