<div class="contentiframe">
<iframe id="contentiframe" src="https://www.youtube.com/embed/4no-3jgS1Mo" onload="resizeIframe()" style="min-height:500px;"></iframe>
</div>
/* @content-iframe */
.contentiframe {
text-align: center;
iframe {
width: 100%;
height: auto;
border: none;
outline: none;
max-width: 1150px;
margin: 0 auto;
overflow: hidden;
}
}
import $ from 'jQuery'
function resizeIframe() {
if ($('#contentiframe').length) {
$('#contentiframe').css('height', $('#contentiframe').contents().height() + 'px');
console.log($('#contentiframe').contents().height());
}
}
$( document ).ready(function() {
resizeIframe();
});
<?php
$contentiframe = array (
'key' => 'contentiframe',
'label' => 'Content iFrame',
'name' => 'contentiframe',
'type' => 'repeater',
'instructions' => '',
'sub_fields' => array (
array(
'key' => 'contentiframe__url',
'label' => 'Content iFrame URL',
'name' => 'url',
'type' => 'url',
'instructions' => '',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
),
array(
'key' => 'hide_block',
'label' => 'Hide this block from anchor links',
'name' => 'hide_block',
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'message' => '',
'default_value' => 0,
'ui' => 1,
'ui_on_text' => '',
'ui_off_text' => '',
),
array(
'key' => 'contentiframe__minheight',
'label' => 'Content iFrame Min Height',
'name' => 'minheight',
'type' => 'number',
'instructions' => '',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
),
),
'row_min' => 0,
'row_limit' => '',
'layout' => 'row',
);
array_push($_SESSION["blocks"], $contentiframe);