TransWikia.com

How to make float element in tinymce

WordPress Development Asked by KeizerBridge on January 6, 2022

I would know how its possible to add a float:left or float:right in tinymce ?
I know how to do this for a picture but what is the best solutions for all elements ?

One Answer

You could add custom quick tags (for the text editor) easily as follows

function wpse182089_add_float_quicktags() {
    if (wp_script_is('quicktags')){ ?>
        <script type="text/javascript">
        QTags.addButton( 'floatr', 'float right', '<span style="float: right">', '</span>', '', '', 41 );
        QTags.addButton( 'floatl', 'float left', '<span style="float: left">', '</span>', '', '', 42 );
        </script>
    <?php }
}
add_action( 'admin_print_footer_scripts', 'wpse182089_add_float_quicktags' );

You could change the span to div if you want to.

Answered by jimihenrik on January 6, 2022

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP