-1

PHPでiframeの幅と高さを変更する方法を体に教えてもらえますか?データベースでは、以下の形式で保存しています。表示している間、固定サイズにします。

これはiframeコンテンツです

<iframe width="400" height="225" src="http://www.youtube.com/embed/c7ct6pNOvEE?feature=oembed" frameborder="0" allowfullscreen></iframe>

Here width & height changes dynamicallysite.thenに基づいて、phpで幅を500に、高さを350に変換する方法

前もって感謝します

4

1 に答える 1

7

CSSを使用する必要があります

html, body, iframe {
    height: 100%;
    width: 100%;
}

編集: 次回は、質問を適切に定義し、投稿する前に適切な説明を追加する必要があります。

とにかく、データベースにサイズがあるので、エコーを使用してサイズを変更するだけです。最初にデータベースから幅と高さを取得し、それを HTML にエコーする必要があります。

<?php
$iframe = html_entity_decode($post['url']);
$newWidth = 610;
$newHeight = 450;
?>

<iframe
    src="<?php echo $iframe; ?>"
    height="<?php echo $newHeight; ?>"
    width="<?php echo $newWidth; ?>"
    frameborder="0" allowfullscreen>
</iframe>

v12351524274573523 を編集

$iframe = '<iframe width="400" height="225" src="youtube.com/embed/c7ct6pNOvEE?feature=oembed" frameborder="0" allowfullscreen></iframe>';

$src = html_entity_decode($post['url']);
$height = 450;
$width = 610;

// add autoplay
$src = $src . (strstr($src, '?') ? '&': '?') . 'autoplay=1';

$iframe = preg_replace('/src="(.*?)"/i', 'src="' . $src .'"', $iframe);
$iframe = preg_replace('/height="(.*?)"/i', 'height="' . $height .'"', $iframe);
$iframe = preg_replace('/width="(.*?)"/i', 'width="' . $width .'"', $iframe);
于 2013-01-22T12:40:48.817 に答える