Title: TinyMCE button
Last modified: April 2, 2017

---

# TinyMCE button

 *  Resolved [nht2007](https://wordpress.org/support/users/nht2007/)
 * (@nht2007)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/tinymce-button-2/)
 * Hello,
    Please tell me know how to add custom shortcode button to MCE, I try 
   to hook ‘init’ but it’s not working. Please help

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Contributor [Ben Carlo](https://wordpress.org/support/users/hinampaksh/)
 * (@hinampaksh)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/tinymce-button-2/#post-9019782)
 * Hey [@nht2007](https://wordpress.org/support/users/nht2007/),
 * Thanks for posting! And apologies for the delayed response. Do you mind sharing
   the code you’re using so we can check? 🙂
 * Ben
 *  Thread Starter [nht2007](https://wordpress.org/support/users/nht2007/)
 * (@nht2007)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/tinymce-button-2/#post-9021298)
 * Hey [@ben](https://wordpress.org/support/users/ben/) Carlo
 * My shortcode:
 *     ```
       // Lazy Shortcode
       function lazyimage_shortcode( $atts ) {
   
           // Attributes
           $atts = shortcode_atts(
               array(
                   'tieude' => '',
                   'url'    => ''
               ),
               $atts,
               'lazyimage'
           );
   
           return '<img class="lazy loading" data-src="'.esc_html__($atts['url']).'" alt="'.esc_html__($atts['tieude']).'" title="'.esc_html__($atts['tieude']).'">';
   
       }
       add_shortcode( 'lazyimage', 'lazyimage_shortcode' );
   
       // Add TinyMCE button and plugin filters
       function lazyimage_tinymce_button() {
           if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) {
               add_filter( 'mce_buttons', 'lazyimage_register_tinymce_button' );
               add_filter( 'mce_external_plugins', 'lazyimage_tinymce_button_script' );
           }
       }
       add_action( 'init', 'lazyimage_tinymce_button' );
       ```
   
    -  This reply was modified 9 years, 1 month ago by [nht2007](https://wordpress.org/support/users/nht2007/).
 *  Plugin Contributor [Ben Carlo](https://wordpress.org/support/users/hinampaksh/)
 * (@hinampaksh)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/tinymce-button-2/#post-9028031)
 * Hey [@nht2007](https://wordpress.org/support/users/nht2007/),
 * Can you try adding your filters at a high priority and see if it works? 🙂
 *     ```
       // Lazy Shortcode
       function lazyimage_shortcode( $atts ) {
   
           // Attributes
           $atts = shortcode_atts(
               array(
                   'tieude' => '',
                   'url'    => ''
               ),
               $atts,
               'lazyimage'
           );
   
           return '<img class="lazy loading" data-src="'.esc_html__($atts['url']).'" alt="'.esc_html__($atts['tieude']).'" title="'.esc_html__($atts['tieude']).'">';
   
       }
       add_shortcode( 'lazyimage', 'lazyimage_shortcode' );
   
       // Add TinyMCE button and plugin filters
       function lazyimage_tinymce_button() {
           if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) {
               add_filter( 'mce_buttons', 'lazyimage_register_tinymce_button', 99999 );
               add_filter( 'mce_external_plugins', 'lazyimage_tinymce_button_script', 99999 );
           }
       }
       add_action( 'init', 'lazyimage_tinymce_button' );
       ```
   
 * Ben
    -  This reply was modified 9 years, 1 month ago by [Ben Carlo](https://wordpress.org/support/users/hinampaksh/).
 *  Thread Starter [nht2007](https://wordpress.org/support/users/nht2007/)
 * (@nht2007)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/tinymce-button-2/#post-9029179)
 * [@hinampaksh](https://wordpress.org/support/users/hinampaksh/) wow, It’s worked.
   
   Awesome, thank you so so much
 *  Plugin Contributor [Ben Carlo](https://wordpress.org/support/users/hinampaksh/)
 * (@hinampaksh)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/tinymce-button-2/#post-9032061)
 * No worries at all! Glad we could help. 🙂
 * Enjoy BB!
 * Ben

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘TinyMCE button’ is closed to new replies.

 * ![](https://ps.w.org/beaver-builder-lite-version/assets/icon-256x256.png?rev=
   2361183)
 * [Beaver Builder Page Builder - Drag and Drop Website Builder](https://wordpress.org/plugins/beaver-builder-lite-version/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/beaver-builder-lite-version/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/beaver-builder-lite-version/)
 * [Active Topics](https://wordpress.org/support/plugin/beaver-builder-lite-version/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/beaver-builder-lite-version/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/beaver-builder-lite-version/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Ben Carlo](https://wordpress.org/support/users/hinampaksh/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/tinymce-button-2/#post-9032061)
 * Status: resolved