Forums | Mahara Community

Support /
Removing the image button on the TinyMCE toolbar


Richard Samson's profile picture
Posts: 17

29 November 2024, 10:19

We have had some problems with users putting too much text and too many images in text blocks. (This seems to happen when users prepare content in MS Word and then copy it into Mahara. We try to discourage using Mahara like a word processor, but old habits die hard.) Anyway, massive text blocks can crash a whole page in Mahara. 

One option that we think could reduce pain is to remove the image button and image plugin from the TinyMCE instance in Mahara. Users can already resort to the Image block to add images to their portfolio. They don't need to insert images in text blocks.

Any comments on this? Is this a reasonable configuration adjustment? The TinyMCE editor is only used in the Text block, isn't it? Any downsides?  

Thanks in advance.

Robert Lyon's profile picture
Posts: 778

29 November 2024, 13:53

Hi Richard,

The problem of putting too much content into a text block is something we are trying to resolve but there is the problem of visible content length versus the content with HTML markup. When pasting something from Word it can bring along a lot of hidden HTML styling info as well.

So when saving the content it ends up being  bigger than we expect.

The TinyMCE editor does have some buttons to help with things. If they toggle the TinyMCE toolbar (top left button) to see the extra options there is the 'clear formatting' and 'paste as text' buttons to use.

To turn off the Image plugin it would be for all instances of TinyMCE on the site and to do that you'd need to edit the $toolbar_row_two line in the htdocs/lib/web.php file and remove the option for '| imagebrowser'.

Cheers

Robert

Richard Samson's profile picture
Posts: 17

02 December 2024, 3:27

Thanks, Robert.

This is really useful.

On second thoughts, I see that the image plugin and button are also used in editing journal entries, notes and comments, among others, so it's probably not a good idea to disable them globally.

We just wonder what best practice should be to avoid problems. Then again, unfortunately, best practice is often only followed by the most careful users, which tempts us to look for more heavy-handed solutions!

Richard Samson's profile picture
Posts: 17

02 December 2024, 4:41

I see that TinyMCE suggest an alternative approach:

This script shows an alert if the length is excessive, without proceeding to save the content.

Don't you think that this is a good option?

 

Robert Lyon's profile picture
Posts: 778

03 December 2024, 9:52

Hi Richard,

On further examination of the Mahara code I see we already have a way to limit the amount of content in a TinyMCE editor.

Looking at the profile page of an account we can see the Wall block and the TinyMCE instance there is restricted to 1500 characters.

It is done via the pieform rules option on the element, eg:

'rules' => array('maxlength' => 1500)

option.

So we'd need to have similar rules on other forms that have a TinyMCE field to limit the maximum input.

Cheers

Robert

 

Richard Samson's profile picture
Posts: 17

04 December 2024, 0:09

Thanks for this, Robert.

It looks like what we want. I will try this and tell you how it goes.

Kristina Hoeppner's profile picture
Posts: 4893

20 December 2024, 10:58

Hi Richard,

The image button doesn't produce the results that you shared. That only essentially inserts a link to an image. The student would have copied and pasted an image (or drag-dropped it in), thus circumventing the image button. That turns an image into a base64 one which then has lots of characters. That's prevented since Mahara 24.04.7.

Thank you

Kristina

Richard Samson's profile picture
Posts: 17

08 January 2025, 8:36

Thanks for the clarification, Kristina. I cannot reproduce the error with images on our 24.04.4 platform. Maybe I have not tried all the possible copy and paste options.

But anyway, we are testing Mahara 24.04.8 right now. And it still allows the user to paste long texts in a text block that after saving renders the page unavailable for further viewing/editing. So we will probably try to apply the TinyMCE coding solution that Robert has suggested above in this conversation.

I'll let you know how it goes!

8 results