(https://i.imgur.com/kj9cqzE.jpg)
(http://blob:https://imgur.com/c02b9e81-39af-4245-8bbd-6bd5a53176c4)
(https://i.imgur.com/x0wh6Y5.jpg)
ทำตัวเล่นวีดีโอ แบบ iframe แต่ยังไม่ได้เพิ่มเป็น src="" เปล่าๆๆ อยากทำ iframe default แก้ขัดไปก่อน
++ ดันๆๆๆ หน่อย
ใส่ไปตรงๆเลยไม่ได้ครับ
ต้องประยุกต์ ใช้ js ช่วย แบบ preloader
ประมาณว่า สร้าง div มารอสักอัน จะใส่ข้อความ แต่ง css อะไรก็จัดไป
แล้วให้ใช้ js ตรวจจับว่า ใน div มี data-src ไหม ถ้ามีก็ให้ div กลายร่างเป็น iframe
<div data-src="xxx.ooo">Hello, World.</div>
น่าสนใจเหมือนกัน ลองทำบ้างครับ :P
อ้างถึงจาก: BOS ใน 07 ตุลาคม 2023, 17:10:35
ใส่ไปตรงๆเลยไม่ได้ครับ
ต้องประยุกต์ ใช้ js ช่วย แบบ preloader
ประมาณว่า สร้าง div มารอสักอัน จะใส่ข้อความ แต่ง css อะไรก็จัดไป
แล้วให้ใช้ js ตรวจจับว่า ใน div มี data-src ไหม ถ้ามีก็ให้ div กลายร่างเป็น iframe
<div data-src="xxx.ooo">Hello, World.</div>
ไม่มีความรู้เลยครับแบบนี้ แล้ว iframe ต้องใส่ยังไงทำ div js ยังไงครับ :wanwan017:
อ้างถึงจาก: iammee ใน 09 ตุลาคม 2023, 11:25:15
อ้างถึงจาก: BOS ใน 07 ตุลาคม 2023, 17:10:35
ใส่ไปตรงๆเลยไม่ได้ครับ
ต้องประยุกต์ ใช้ js ช่วย แบบ preloader
ประมาณว่า สร้าง div มารอสักอัน จะใส่ข้อความ แต่ง css อะไรก็จัดไป
แล้วให้ใช้ js ตรวจจับว่า ใน div มี data-src ไหม ถ้ามีก็ให้ div กลายร่างเป็น iframe
<div data-src="xxx.ooo">Hello, World.</div>
ไม่มีความรู้เลยครับแบบนี้ แล้ว iframe ต้องใส่ยังไงทำ div js ยังไงครับ :wanwan017:
https://codepen.io/bestspacejam/pen/GQeveR
https://stackoverflow.com/questions/31134958/placeholder-content-for-iframe
อ้างถึงจาก: iammee ใน 09 ตุลาคม 2023, 11:25:15
อ้างถึงจาก: BOS ใน 07 ตุลาคม 2023, 17:10:35
ใส่ไปตรงๆเลยไม่ได้ครับ
ต้องประยุกต์ ใช้ js ช่วย แบบ preloader
ประมาณว่า สร้าง div มารอสักอัน จะใส่ข้อความ แต่ง css อะไรก็จัดไป
แล้วให้ใช้ js ตรวจจับว่า ใน div มี data-src ไหม ถ้ามีก็ให้ div กลายร่างเป็น iframe
<div data-src="xxx.ooo">Hello, World.</div>
ไม่มีความรู้เลยครับแบบนี้ แล้ว iframe ต้องใส่ยังไงทำ div js ยังไงครับ :wanwan017:
https://codepen.io/60ss/pen/WNLPNZr
อ้างถึงจาก: BOS ใน 09 ตุลาคม 2023, 20:30:53
อ้างถึงจาก: iammee ใน 09 ตุลาคม 2023, 11:25:15
อ้างถึงจาก: BOS ใน 07 ตุลาคม 2023, 17:10:35
ใส่ไปตรงๆเลยไม่ได้ครับ
ต้องประยุกต์ ใช้ js ช่วย แบบ preloader
ประมาณว่า สร้าง div มารอสักอัน จะใส่ข้อความ แต่ง css อะไรก็จัดไป
แล้วให้ใช้ js ตรวจจับว่า ใน div มี data-src ไหม ถ้ามีก็ให้ div กลายร่างเป็น iframe
<div data-src="xxx.ooo">Hello, World.</div>
ไม่มีความรู้เลยครับแบบนี้ แล้ว iframe ต้องใส่ยังไงทำ div js ยังไงครับ :wanwan017:
https://codepen.io/60ss/pen/WNLPNZr
พอดีผมใช้ตัวนี้ครับ [iframe id="player" class="player" src="" width="100%" height="500" allowfullscreen=""]
https://wordpress.org/plugins/iframe/
อ้างถึงจาก: iammee ใน 10 ตุลาคม 2023, 10:56:35
พอดีผมใช้ตัวนี้ครับ [iframe id="player" class="player" src="" width="100%" height="500" allowfullscreen=""]
https://wordpress.org/plugins/iframe/
งั้นก็ทำย้อนกลับ ให้ iframe ที่ไม่มี src กลายร่างเป็น div ครับ
https://codepen.io/60ss/pen/Jjwxwbw
อ้างถึงจาก: BOS ใน 10 ตุลาคม 2023, 23:38:51
อ้างถึงจาก: iammee ใน 10 ตุลาคม 2023, 10:56:35
พอดีผมใช้ตัวนี้ครับ [iframe id="player" class="player" src="" width="100%" height="500" allowfullscreen=""]
https://wordpress.org/plugins/iframe/
งั้นก็ทำย้อนกลับ ให้ iframe ที่ไม่มี src กลายร่างเป็น div ครับ
https://codepen.io/60ss/pen/Jjwxwbw
ไม่มีอะไรเกิดขึ้นเลยครับ
(https://i.imgur.com/xcQ7XiY.jpg)
(https://i.imgur.com/zzKuSKg.jpg)
(https://i.imgur.com/kEMCQH0.jpg)
<?php
/*
Plugin Name: iframe
Plugin URI: http://wordpress.org/plugins/iframe/
Description: [iframe src="http://www.youtube.com/embed/dUpTjDqjQoo" width="100%" height="500"] shortcode
Version: 4.9
Author: webvitaly
Author URI: http://web-profile.net/wordpress/plugins/
License: GPLv3
*/
if ( ! defined( 'ABSPATH' ) ) { // Avoid direct calls to this file and prevent full path disclosure
exit;
}
define('IFRAME_PLUGIN_VERSION', '4.9');
function iframe_plugin_add_shortcode_cb( $atts ) {
$defaults = array(
'src' => 'http://www.youtube.com/embed/dUpTjDqjQoo',
'width' => '100%',
'height' => '500',
'scrolling' => 'yes',
'class' => 'iframe-class',
'frameborder' => '0'
);
$allowed_tags = array(
'h1' => array(),
'h2' => array(),
'h3' => array(),
'h4' => array(),
'h5' => array(),
'h6' => array(),
'p' => array(),
'a' => array(
'href' => true,
'title' => true,
),
'br' => array(),
'em' => array(),
'strong' => array()
);
foreach ( $defaults as $default => $value ) { // add defaults
if ( ! @array_key_exists( $default, $atts ) ) { // mute warning with "@" when no params at all
$atts[$default] = $value;
}
}
$html = "
".'<!-- iframe plugin v.'.IFRAME_PLUGIN_VERSION.' wordpress.org/plugins/iframe/ -->'."
";
$html .= '<iframe';
foreach( $atts as $attr => $value ) {
if ( strtolower($attr) == 'src' ) { // sanitize url
$value = esc_url( $value );
}
if ( strtolower($attr) == 'srcdoc' ) { // sanitize html
$value = htmlspecialchars_decode( $value );
$value = wp_kses( $value, $allowed_tags );
$value = esc_html( $value );
}
// Remove all attributes starting with "on". Examples: onload, onmouseover, onfocus, onpageshow, onclick
if ( strpos( strtolower( $attr ), 'on' ) !== 0 ) {
if ( $value != '' ) { // adding all attributes
$html .= ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"';
} else { // adding empty attributes
$html .= ' ' . esc_attr( $attr );
}
}
}
$html .= '></iframe>'."
";
if ( isset( $atts["same_height_as"] ) ) {
$html .= '
<script>
document.addEventListener("DOMContentLoaded", function(){
var target_element, iframe_element;
iframe_element = document.querySelector("iframe.' . esc_attr( $atts["class"] ) . '");
target_element = document.querySelector("' . esc_attr( $atts["same_height_as"] ) . '");
iframe_element.style.height = target_element.offsetHeight "px";
});
</script>
';
}
return $html;
}
add_shortcode( 'iframe', 'iframe_plugin_add_shortcode_cb' );
function iframe_plugin_row_meta_cb( $links, $file ) {
if ( $file == plugin_basename( __FILE__ ) ) {
$row_meta = array(
'support' => '<a href="http://web-profile.net/wordpress/plugins/iframe/" target="_blank">' . __( 'Iframe', 'iframe' ) . '</a>',
'donate' => '<a href="http://web-profile.net/donate/" target="_blank">' . __( 'Donate', 'iframe' ) . '</a>',
'pro' => '<a href="https://1.envato.market/Ym5aq" target="_blank">' . __( 'Advanced iFrame Pro', 'iframe' ) . '</a>'
);
$links = array_merge( $links, $row_meta );
}
return (array) $links;
}
add_filter( 'plugin_row_meta', 'iframe_plugin_row_meta_cb', 10, 2 );
ใครพอช่วยแก้ได้ไหมครับ