LTI Message Handler

LTI sources ::: ltisource_message_handler
Maintained by Colin Perepelken, WCLN logoWestern Canadian Learning Network
This Moodle LTI Source plugin allows communication between an LTI tool and a consumer site.
Latest release:
162 sites
9 fans
Current versions available: 1

LTI Message Handler

by Western Canadian Learning Network.  

This Moodle LTI Source plugin allows communication between an LTI tool and a consumer site. It is meant to replicate message handling functions implemented in Canvas. Thus, if an LTI provider makes use of Canvas' functions, this plugin will work similarly.    

The main purpose of this plugin is to allow iFrame resizing. The LTI iFrames in Moodle are laughably small and impossible to view course content in. With this plugin installed, an LTI tool provider may send messages to the tool consumer instructing it to resize the iFrame.  

See the screenshots which show an LTI book with and without this plugin installed.  


This plugin should be installed on the tool consumer site. See "Usage" for how to make use of this plugin as a tool provider.

  • Download this repository.  
  • Extract the ZIP to 'mod/lti/source/'.  
  • The folder name within the source directory should be "message_handler".  
  • Login to your Moodle site as an administrator and install the plugin.


  • Login to your Moodle site as an admin and go to Administration -> Site administration -> Plugins -> Install plugins.  
  • Upload the ZIP file.  


Once the plugin is installed on the tool consumer site, the tool provider may communicate with it as follows.

// Send message to the tool consumer to resize the iframe. Height will be accepted as an integer or a string.
window.parent.postMessage(JSON.stringify({subject: 'lti.frameResize', height: 1000}), '*');
// Send message to the tool consumer to resize the iframe.
window.parent.postMessage(JSON.stringify({subject: 'lti.scrollToTop'}), '*');
// Send a message to the tool consumer to remove the iframe border. window.parent.postMessage(JSON.stringify({subject: 'lti.removeBorder'}), '*');

For example, if a tool provider is returning a page 'index.html' to be displayed in the iframe, they should add a JavaScript file similar to above.

Note: While you can install this plugin on your site receiving LTI content, the LTI provider must implement one of the above to actually use the functions.

Possible message subjects:  

  • lti.frameResize  
  • lti.scrollToTop  
  • lti.removeBorder

If you enjoyed this plugin, please vote for it to be included in Moodle core!

Created by Colin Perepelken for Western Canadian Learning Network.


Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3


Colin Perepelken (Lead maintainer)
WCLN logo
Western Canadian Learning Network
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Plugins bot
    Fri, Feb 15, 2019, 3:00 PM
    Approval issue created: CONTRIB-7623
  • Laurent Dairaine
    Fri, Mar 1, 2019, 4:01 PM
    Thank you for this great plugin. Could it be possible to have a LTI message implementing a dynamic height setting, depending of real size of consumer page ?
  • Colin Perepelken
    Mon, Mar 4, 2019, 4:09 AM
    You are very welcome! Glad it could be of use. Unfortunately I don't believe what you are looking for would work. The height of the consumer page area is dependent on the height of the iframe (content). Not the other way around.
  • Laurent Dairaine
    Mon, Mar 4, 2019, 4:30 AM
    Sorry, just a bug in my question...I was asking about a LTI message implementing a dynamic height setting depending of the real size of the PROVIDER page (not consumer). In fact, I try to connect with LTI two moodle instances and I would like to use (short) courses of a first instance from the other one. But I don't know before what will be the size of the content because it depends on the course included. So it is why I would need this dynamic height message. Thanks for your help!
  • Colin Perepelken
    Mon, Mar 4, 2019, 4:39 AM
    Hmm I believe the current function lti.frameResize should work for what you need. Within your provider code, I would create some JavaScript code which runs once you know the size of the content, perhaps on a body onload? In my examples above I provided "height: 1000". However, you can use JavaScript/JQuery to detect the size of the course content and provide the height of that, for example height = $('#some-div').outerHeight(false). That is how I am using this plugin with my own custom provider.

    However, it sounds like you might be using Moodle's built in LTI provider functionality? I haven't tested this plugin with that, as it is intended for custom provider applications in which you can implement your own functions to send messages. If you are using Moodle's built in LTI provider, you may have to edit that core code to send the frameResize messsages.
  • Alex Keiller
    Tue, May 16, 2023, 5:11 PM
    Good day
    We're planning to upgrade to Moodle 4.1. Would the current version of the plugin work on Moodle 4.x?
  • Dean Montgomery
    Fri, Aug 11, 2023, 11:14 PM
    Good morning. We have upgraded to Moodle 4.2 in order to keep on top of security and vulnerability issues of older versions of Moodle and PHP. Is your module going to be updated or is it End-Of-Life?
Please login to post comments