在使用Wordpress的默认媒体管理器将视频插入tinyMCE时,是否有任何方法可以更改默认输出。目前,它将其作为链接插入,是否可以将其作为所有属性完整的iFrame输入编辑器。
提前感谢!
在使用Wordpress的默认媒体管理器将视频插入tinyMCE时,是否有任何方法可以更改默认输出。目前,它将其作为链接插入,是否可以将其作为所有属性完整的iFrame输入编辑器。
提前感谢!
从我的答案中复制粘贴,但添加了iframe/video mime类型:
Alter image output in content
function WPSE_80145_Mime($html, $id) {
//fetching attachment by post $id
$attachment = get_post($id);
$mime_type = $attachment->post_mime_type;
//get an valid array of video types, add any extra ones you need
$image_exts = array( \'video/mpeg\', \'video/mp4\', \'video/quicktime\' );
//checking the above mime-type
if (in_array($mime_type, $image_exts)) {
// the image link would be great
$src = wp_get_attachment_url( $id );
// enter you custom output here,
//you will want to change this to what you want in the iframe
$html = \'<iframe><a href="\' . $src . \'"></a></iframe>\';
return $html; // return new iframe wrapped video via $html
}
return $html;
}
add_filter(\'media_send_to_editor\', \'WPSE_80145_Mime\', 20, 2);
为此,您必须切换到编辑器中的HTML(我认为它被称为3.5中的文本)选项卡,并在那里插入iframe的HTMML代码。这在网络安装或用户角色不是编辑器或管理员时不起作用。
我在跟踪this turial 介绍如何在WordPress中向TinyMCE编辑器添加自定义按钮。试图编辑作者的JS以包含我的功能,但它似乎已被缓存。文章作者对此有一个技巧(下面的代码片段),它第一次成功了(按钮现在在工具栏中),尽管它不适用于后续刷新。// \"This will intercept the version check and increment the current version number by 3. // It\'s the quick and dirty way