Automatically resize iframe if no height was provided.
This commit is contained in:
parent
747607fe97
commit
439aee0a82
|
@ -199,10 +199,15 @@ function oembed_format_object($j){
|
||||||
}
|
}
|
||||||
|
|
||||||
function oembed_iframe($src,$width,$height) {
|
function oembed_iframe($src,$width,$height) {
|
||||||
|
|
||||||
if(! $width || strstr($width,'%'))
|
if(! $width || strstr($width,'%'))
|
||||||
$width = '640';
|
$width = '640';
|
||||||
if(! $height || strstr($height,'%'))
|
if(! $height || strstr($height,'%')) {
|
||||||
$height = '300';
|
$height = '300';
|
||||||
|
$resize = 'onload="resizeIframe(this);"';
|
||||||
|
} else
|
||||||
|
$resize = '';
|
||||||
|
|
||||||
// try and leave some room for the description line.
|
// try and leave some room for the description line.
|
||||||
$height = intval($height) + 80;
|
$height = intval($height) + 80;
|
||||||
$width = intval($width) + 40;
|
$width = intval($width) + 40;
|
||||||
|
@ -210,7 +215,7 @@ function oembed_iframe($src,$width,$height) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$s = $a->get_baseurl()."/oembed/".base64url_encode($src);
|
$s = $a->get_baseurl()."/oembed/".base64url_encode($src);
|
||||||
return '<iframe class="embed_rich" height="' . $height . '" width="' . $width . '" src="' . $s . '" frameborder="no" >' . t('Embedded content') . '</iframe>';
|
return '<iframe '.$resize.' class="embed_rich" height="'.$height.'" width="'.$width.'" src="'.$s.'" frameborder="no">'.t('Embedded content').'</iframe>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
function resizeIframe(obj) {
|
||||||
|
obj.style.height = 0;
|
||||||
|
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
|
||||||
|
}
|
||||||
|
|
||||||
function openClose(theID) {
|
function openClose(theID) {
|
||||||
if(document.getElementById(theID).style.display == "block") {
|
if(document.getElementById(theID).style.display == "block") {
|
||||||
|
|
Loading…
Reference in a new issue