You need to log in to create posts and topics.

Possible To Disable Insert Image / Link?

Is there a way to prevent users from inserting images or inserting links?  A way to remove the option entirely from the toolbar when posting.

Hello hauntedpixel,

please add the following code to your themes functions.php file to remove the buttons for links and images:

function myplugin_tinymce_buttons( $buttons ) {
  $remove1 = 'image';
  $remove2 = 'link';

  if (($key = array_search($remove1, $buttons)) !== false) {
    unset($buttons[$key]);
  }

  if (($key = array_search($remove2, $buttons)) !== false) {
    unset($buttons[$key]);
  }

  return $buttons;
}
add_filter('mce_buttons', 'myplugin_tinymce_buttons', 10000, 2);
add_filter('teeny_mce_buttons', 'myplugin_tinymce_buttons', 10000, 2);

 

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Much appreciated.  Thank you!

Hi,
thank you for this code, it works 😉

But if i update my theme i have to insert the code again, is there any possibility to save this code at the functions.php so that i must not insert it again?

Is there a possibility that you implement a function to the forum so that i can disallow it from the config directly?

Regards
Olli

Quote from Asgaros on December 11, 2017, 10:43 am

Hello hauntedpixel,

please add the following code to your themes functions.php file to remove the buttons for links and images:

function myplugin_tinymce_buttons( $buttons ) {
  $remove1 = 'image';
  $remove2 = 'link';

  if (($key = array_search($remove1, $buttons)) !== false) {
    unset($buttons[$key]);
  }

  if (($key = array_search($remove2, $buttons)) !== false) {
    unset($buttons[$key]);
  }

  return $buttons;
}
add_filter('mce_buttons', 'myplugin_tinymce_buttons', 10000, 2);
add_filter('teeny_mce_buttons', 'myplugin_tinymce_buttons', 10000, 2);
  1. function myplugin_tinymce_buttons( $buttons ) {
  2. $remove1 = 'image';
  3. $remove2 = 'link';
  4. if (($key = array_search($remove1, $buttons)) !== false) {
  5. unset($buttons[$key]);
  6. }
  7. if (($key = array_search($remove2, $buttons)) !== false) {
  8. unset($buttons[$key]);
  9. }
  10. return $buttons;
  11. }
  12. add_filter('mce_buttons', 'myplugin_tinymce_buttons', 10000, 2);
  13. add_filter('teeny_mce_buttons', 'myplugin_tinymce_buttons', 10000, 2);
function myplugin_tinymce_buttons( $buttons ) {
  $remove1 = 'image';
  $remove2 = 'link';

  if (($key = array_search($remove1, $buttons)) !== false) {
    unset($buttons[$key]);
  }

  if (($key = array_search($remove2, $buttons)) !== false) {
    unset($buttons[$key]);
  }

  return $buttons;
}
add_filter('mce_buttons', 'myplugin_tinymce_buttons', 10000, 2);
add_filter('teeny_mce_buttons', 'myplugin_tinymce_buttons', 10000, 2);

 

 

Hello @olli

In your case it would be the best to put the code in an own custom plugin-file. Here you can find an tutorial:

How to Create a Simple WordPress Plugin

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Hello @asgaros

In my case the code does not work. Instead, it adds a clickable zone (same target than the image) closed to the image :

My image in a topic is left aligned, then all the zone at its right get clickable. And the image itself remains clickable also.

Would you see why ?

Thank you

Hello @alcandau

This code does not have any effect on links/images which are already included inside of posts. Uploaded images via the upload-functionality will also work as before - so if you want to remove them, you have to disable the upload-functionality as well.

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Hello,

Sorry my understanding of the topic was bad. It's clear now.