Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there a good reason why the wp media upload button is not placed within the main edit toolbar, and can we put it there instead of floating above??

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

There is an action 'media_buttons' where these buttons are inserted. Some plugins are using that action to add more buttons, dropdown lists or links. If they had to use the TinyMCE toolbar, they had less room and more restrictions regarding style and JavaScript access.

In short: the current placement is better for plugins.

Moving the default button to the toolbar would probably break some core scripts that depend on that position in the DOM. Maybe you can move it around after onload.

share|improve this answer
    
Thanks for clearing that up toscho :) –  speedypancake Nov 10 '12 at 7:35
add comment

Just a proof of concept, not sure about the implications that @toscho signals, but at first it works as expected.

There's a glitch that makes a huge activation border when the upload button is clicked. Maybe another insertion point could solve it...

moving upload button

add_action( 'admin_head-post.php', 'wpse_72093_move_upload_button' );

function wpse_72093_move_upload_button() {
    ?>
    <script type="text/javascript">
        jQuery(window).load( function() {   
            jQuery("#wp-content-media-buttons")
            .appendTo(".mceToolbarStart.mceToolbarStartButton.mceFirst:first"); 

            jQuery('#content-add_media').html(jQuery('#content-add_media')
            .html()
            .replace('Subir/Insertar ', ''));
        });
    </script>
    <?php
}

Note: the second jQuery command is not shown in the snapshot above. It will remove the text from the button. Replace with your own language.

Reference: jquery remove text partially

share|improve this answer
    
Interesting... thanks for posting that brasofilo. I think I prefer that layout and will play around with it when I get a chance - Cheers –  speedypancake Nov 10 '12 at 7:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.