Advertising sustains the DA. Ads are hidden for members. Join today

InsertFrame - Insert auto-sized iframe in any content

Last updated on
30 April 2025

InsertFrame is an input filter to include frames anywhere in your site.
Frames can be auto resizabled according to content.

Installation

  1. Extract zip file in the modules directory
  2. Enable the module in the admin settings
  3. Add the filter to an input format.

Syntax

[[[<url> width=<w> height=<h> scrolling=<yes|no|auto> className=<class> ID=<id> offset=<offset> transparency=<true|false> wrapper=<html|htmlpage|text>]]]

Where :

  • url : Url of the page
  • w : Size as css declaration (%,px,em) - Default : 100%
  • h : Height as css declaration (%,px,em). if height=100% and url is in the same domain as web site, the height will be ajusted to the real height of the source- Default :100%
  • scrolling : Scrollbar settings. Values from IFRAME tag - Default : no
  • class : Name of a CSS class
  • ID : Id and name of the frame - default iframe1
  • transparency : Allow (true) or not (false) iframe transparency
  • offset : offset is a number to add to correct (if needed) auto calculated height - Default 15
  • wrapper (since 2.x) : InsertFrame can include some externals pages (wrapper). Values can be text, html, or htmlpage.See Features for more details.

URL not starting with http will be considered as relative path.

Examples

  1. To include the page www.myurl.com/myapp.html with auto-height with a width of 100%
               [[[http://www.myurl.com/myapp.html]]]
    
  2. To include the page www.myurl.com/myapp.html with height of 500px and width of 300px
               [[[http://www.myurl.com/myapp.html height=500px width=300px]]]
    
  3. To include a frame of id myframe with the myCSSClass css class
               [[[http://www.myurl.com/myapp.html id=myframe class=myCSSClass]]]
    

Features

Version 1.x :

You can add your own tags (tag=value). To custom code with this tags, you must create a theme function. To do this, add in your template.php a function called yourtheme_insertFrame_custom($onload, $iframe_params). The first param is the default code of onload event, the second, an array of all tags of the filter. You function may return any text that will be add as is in the IFRAME html tag.
You can also theme the function insertFrame_init to add javascript for example.

Example :


// Add javascript
function mytheme_insertFrame_init() {
    drupal_add_js(drupal_get_path('module', 'insertFrame') . '/myinsertFrame.js');    
}

// Add resizing feature if resize=Y
function yourtheme_insertFrame_custom($onload, $iframe_params) {
    if ($iframe_params["resize"] != "Y") {return $onload;}
    return $onload . " onresize='resize(this)'";
}

Theming insertFrame_getURL($url) function, you can customize the url (with token module for example). To theme the function, see this example :

      function yourtemplage_insertFrame_getURL($url) {
        return token_replace($url);
      }    

Version 2.x

  • All tags can be rendered as your own by using themed function (see insertFrame_theme()) or by creating insertFrame_render_<the tag to render> function. Both have two parameters :
    1. $value : Value of the tag
    2. $params : Array of all params and values

    Functions must return html output to render the tag.

    Exemple :

    function insertFrame_render_resize($value, $params) {
        if ($value != "Y") {return "";}
        return "onresize='resize(this)'";}
    } 
    

    By default, all non-themed tags are rendered as is (tag="value"). For example, to add transparency behaviour, type :

       [[[url allowtransparency=true]]]
    

    insertFrame_getURL() and insertFrame_custom() have been deleted. Migrate them to insertFrame_render_url and insertFrame_render_<tag>

    To insert spaces in tag's values, replace them by %20.

       [[[url style="border:1px%20solid%20red"]]]
    
  • Support of Token module for url
  • Wrapper : External pages can be included directly in Drupal, so Drupal theme can be used.
    • Text : Inserted as plain text (surrounded by pre tag)
    • html : Inserted as html fragment page
    • htmlpage : Insert only the body of the html page

2.1 features

  • A setting paramater has been added. Checking it, make relative path from base url, not from parent path

Remarks

  • You can use the filter with wiki modules but you must enclose the lines with <nowiki> tag.
  • if HTML filter is active, add <iframe> in the "Allowed HTML tags" input box in the configure tab of your input format

Help improve this page

Page status: Not set

You can: