Howto: change the notification subject and allow KB images in GLPI version 0.90.3

For version 1.9.2 review:


GLPI released their new version 0.90.3.
With new each release two questions seem to be very persistent. These questions are:

  1. How can we change the default notification prefix: [GLPI ] in the email  subject.
  2. How do we enable images in the KB articles.

In this article you will be able to read my personal  opinion on the matter and how to change this GLPI behavior.

Why do you want to change the GLPI  notification prefix.

The most obvious reason is to allow your customer to quickly identify your companies tickets. The rule of thumb in modern system view design is enabling users to quickly: ‘scan, select. act’ Changing the subject to something intuitive enables your customers to do so.

Another point of interest is the possibility to daisy-chain multiple installations of GLPI. By configuring the notification subjects and schemes correctly you can daisy chain multiple installations allowing cross organization enterprise environments to be set up. This is impossible when all installations identify themselfs as ‘GLPI [key].’

How to alter the code to support your custom prefix in GLPI 0.90

In order to alter the subject prefix in GLPI 0.90,  firstly you need to configure your prefix in the Administration>Entities>[your entity]>notifications>Prefix for notifications. Changing this configuration field will correctly alter the prefix to that of your liking. No further code-hacks are required or advised.

Why do you want images in your KB.

Well this is -in my humble opinion- an no brainer. One images shows more detail then i can describe in a thousand words. Images also help speed up the resolution process, especially during nightly hours. It also allows the engineer to intuitively compare the version of the actual situation with the situation documented. Is it all positive then? no, there are some downsides to consider as well.

An image doesn’t replace the engineers know-how and sometimes you want to explicitly trigger this knowledge by not showing any images. Updated applications might look different, actually slowing down the resolution process. Another more technical downside is web server storage. All images need to be stored somewhere and might needlessly clutter the support-system. My point of view is that you need to decide whats best for your situation. Sadly GLPI doesnt allow you to choose yet, it forces images to be removed. If you do need image support, please apply the code-hack below.

Be aware, This wont enable image export to pdf.

How to enable images in the KB

First we need to enable the INSERT function that enables us to add images using the TinyMCE editor. In order to do this two changes need to be made.

In the inc/html.class.php file on line:3837 and line:3871 comment out ( // ) the lines that reads _html = _html.replace .. See screenshots for more details.

Optionally you can enable the ‘image’ button by adding image to the ‘theme_advanced_buttons2 : ‘ line. See images underneath for more details.


The next step is to enable the images to be shown. Without this change the HTMLAWED plugin will add a denied tag to the actual images effectivly telling the browser not to show the image. Additionally the resulting HTML code including the denied: tag will be stored in database also disabling this specific image after the next code modification. Enabling the images afterward requires an search and replace statement in the database. (See comments below).

In the file /lib/htmlawed/htmLawed.php on line 47 add ‘;src: data’ to the end of the line.

Make sure you use an screenshot tool that generates an inline HTML image on the clipboard. Greenshot is an free alternative that does this out of the box.



26 thoughts on “Howto: change the notification subject and allow KB images in GLPI version 0.90.3

  1. Hi Chris
    Thanks for this, unfortunately the images I paste in are showing up when editing the kb article but not when viewing it.
    This is what the source shows:

    This is for a newly created post, so I’m guessing I’ve missed something obvious

    Any ideas?

    Many thanks


  2. Hi David,

    If my memory serves me right the articles are stored in the database. So you might need to remove the denied: tag from the database table holding the articles html source.

    Please check the next SQL statement on a development database first. It should remove any stored denied: tags from the <img src="denied:base64 html source.

    update glpi_knowbaseitems set answer =REPLACE(answer, 'denied:', '');

  3. Hi Chris.

    I made this changes in brand new GLPI 0.90.3.
    I still can not paste a picture.

    Could you help me?


  4. Hi Richard,

    Sadly we didnt install that version yet. When i find the time I will have a look.

    If i may ask, what tool are you using to paste the images?

    We are using Greenshot ourselfs and works quite nicely.

  5. Hi,
    Thanks for your tips.
    I have made your advice and now i can paste image but when i paste more than one image i have a bug:
    the first image is pasted at the cursor position but the other image was pasted at the begining of the post.
    I have to edit the html code to put the image at the good place.
    Could you help me ?

    1. Hi Vlepetit,

      Im not sure what causes the behavior you describe. This might be an tinyMCE related bug in which case you could search the tinyMCE fora. You might also want to review the changes made in the html.class.php file. Typos might also cause unintended behavior. You might want to review the images above to see my version.

      I hope these tips will help you out.

    2. Same problem for me. Only the first image is correctly placed under the cursor location. I’m looking for solution, but it also happens in 0.90.5.

      And a tip: Images 250KB are not shown “as images”. They are shown as:
      <img src="data:image/png;base64,iVBORw0……………………..
      but only in the global article's view. TinyMCE shows it perfectly.

    3. A workaround for this problem is not only to comment the lines 3837 and 3871 in “html.class.php”, but also: 3836, 3837, 3838, 3839, 3840, 3841, 3842, 3843, 3844, 3845, 3846, 3847, 3870, 3871, 3872 and 3873. Like this:

      if(_html != undefined) {
      // if (_html.match(/]+src=\”data:image.*?;base64[^>]*?>/g)){
      // _html = _html.replace(/]+src=\”data:image.*?;base64[^>]*?>/g, ”);
      // tinyMCE.activeEditor.setContent(_html);
      // } else {
      // that = {
      // e: elem
      // }
      // that.callself = function () {
      // waitforpastedata(that.e)
      // }
      // setTimeout(that.callself,20);
      // }


      paste_preprocess : function(pl, o) {
      _html = o.content;
      // if (_html.match(/]+src=\”data:image.*?;base64[^>]*?>/g)){
      // _html = _html.replace(/]+src=\”data:image.*?;base64[^>]*?>/g, ”);
      // o.content = _html;
      // }


      It is working for me now, but I’m not sure about the reason of why it works 🙂

  6. Also i don’t get the last bit
    In /lib/htmlawed/htmLawed.php:47 alter the $x and add ;src data’ to the end.

    The syntax is all messed up. Can you specify where the ;src data’ should be added?

  7. Ok now i can add the last src:data correct but when i copy a picture it only adds a tag with nothing in it.

    Thanks by the way for the pictures.

  8. Hi Chris,

    Probably on you environment works fine. But I just tried on 90.4 do the same actions as you wrote. Line numbers match. But by default “In the inc/html.class.php file on line:3837 and line:3871 comment out ( // )” lines are not commented. And seems that by default image paste should be work. But something is stops to paste in and create <img src:data content.

    1. Hi Tadas,

      There are two components that you need to take into account. Firstly TinyMCE has an editing function (past) and view function (content in the tinyMCE editor). The second component is the content shown by GLPI when it is not being edited.

      Concerning the tinyMCE component.

      The lines you describe are part of the input and output filters used by tinyMCE. The specific lines use a regex formula to find all [<img src="data:image base64] tags in the input (paste) and output (print) functions of tinyMCE and replace them with nothing ''. This effectively removes the images. But only within tinyMCE.

      Putting a comment in front of those lines will stop tinyMCE from replacing these image tags with nothing. Effectively allowing images to be processed and being passed to GLPI.

      Concerning GLPI.

      When the content is passed by tinyMCE to GLPI it is saved in the GLPI database. Before the content is actually saved in the database it is 'made save' and being filtered by the htmLawed lib. The default behaviour of this lib is to add the html tag :disabled to all 'unallowed' html tags. Adding the img src as allowed tag will stop the htmLawed lib from adding :disabled to the image tags. This will effectively allow images to be shown in KB articles when they are being viewed from GLPI.

      Be aware, once content is saved in the database without this modification, the saved content will have this :disabled tag and will not show up. Not even after changing the htmLawed module. To fix this i spammed a 'search replace' sql statement somewhere in the comments.

      Hope this helps understanding the change in more depth.

  9. in addition,

    Be sure you have an snippet tool that stores the images on the clipboard in an ‘inline HTML’ format. If you are not sure about this, please download Greenshot (opensource) and give that tool a go.

    The previous poster got his issues fixed by downloading and using Greenshot.

  10. Chris,
    Your post is really interesting.
    I can’t manage to get image paste possible in the KB.
    My GLPI version is 090.0.1.
    So, the “rich text” option is set.
    Both files “html.class.php” and “htmLawed.php” have been modified.
    Nevertheless, I can’t manage to paste images through the editor (via Lightshot : I also have tried your tool, without success).

    Any clue?
    Thanks in advance,
    Tests have been implemented with chrome and FF browsers.


  11. Few things you could do:

    Input filters?
    1. Verify that the base64 encoding of the is stored in the glpi database;
    >select answer from glpi_knowbaseitems where answer like ‘%data:image/png;base64%’ limit 1;
    2. Verify that the ‘denied:’ isnt stored with the image in the database. Fix would be a search/replace on the denied: string. Make sure to backup the database prior. The stored value should look something like: <img src=”data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA6c

    2. Output filters
    If the content is stored as expected please review the htmlLawed configuration. It prob is still adding denied: to the output.

    In addition make sure to use greenshot, it has this special feature that stores the base64 encoding. Many tools dont do this, and wont have the expected result when pasted into the wysiwyg

  12. Chris,
    Thanks again.
    While analyzing the data in the base, I add this in the file “htmLawed.php”:
    data:image,data; src: data
    In the file “html.class.php”, I add this setting for the TinyMce Editor :
    “paste_data_images: true,” (line 3927).
    I have also upgraded to version 9_1_2 (lastest one).
    + your modifications in the file “htmLawed.php”.

    At the end, it both works for the ticket and the KB, while creating them or consulting them when closed.


  13. Chris,

    Everything seems to be ready, except receiving correct mail in the notification process.

    The html file included in the field queued_mails.body_html contains for my scheme :
    <img src, instead of <img src…
    The same for src=" instead of src="

    This is the content of ##ticket.description##, it contains the image (base64) for the ticket.

    ##ticket.description## doesn't seem to be parsed.

    So, in the mail, the message doesn't contain correct hmtl code for the pasted image and therefore the image is not displayed.

    I don't know where to change this behaviour.
    Have you got an idea?

    At last, I could build a trigger on the database…

    Thanks in advance.


    1. Hi Ay,

      If i find some time (somewhere next month or so) i might look into this.

      BUT… 🙂

      We didn’t implement this on our side for various reasons .

      1. Whether or not the images are parsed on the receiving side is mainly up to the mail-client. We know there are various compatibility issues when it comes to mail clients.
      For example: If you rely on this functionality from a service perspective you might have all kinds of issues. Next to that there are many client side settings that may end up breaking this functionality. Which makes delivering quality hard. My advice: use the GLPI notification templates to add nice makeup and keep the mail body text only as much as possible.

      2. The reason this keeps breaking is because the proper way of doing this is to add an mail attachment and relate to that attachment in the mail body. You can do this by means of the CID/MID urls. Again this approach is also sensitive for tons of security related issues. Imagine GLPI being used as a spam/viral relay if configured to accept all unknown senders. Again my advice keep the notifications as texy as possible and use the notification templates (source you can control) to add nice layouts.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s