admin管理员组文章数量:1130349
My users have sprung a requirement on me that I am having some difficulty figuring out. I've tied myself up in knots trying to unravel the the logic needed.
The original spec of this website I am building called for the a video to be autoplaying on pageload as a showreel in the header section (I know, I know! They won't listen).
I added a filter to append the embed URL with the autoplay options etc.
add_filter('oembed_result', [$this,'modifyEmbedCode']);
public function modifyEmbedCode($html){
$result=str_replace("?app_id=122963", "?app_id=122963&loop=1&background=1&autoplay=1", $html);
return $result;
}
This works fine but now they want to still be able to embed a video in the WYSIWYG editor and have it retain the standard Vimeo controls and not to autoplay.
Is there a way to make the filter context-aware and only be applied when the_content is NOT being outputted?
My users have sprung a requirement on me that I am having some difficulty figuring out. I've tied myself up in knots trying to unravel the the logic needed.
The original spec of this website I am building called for the a video to be autoplaying on pageload as a showreel in the header section (I know, I know! They won't listen).
I added a filter to append the embed URL with the autoplay options etc.
add_filter('oembed_result', [$this,'modifyEmbedCode']);
public function modifyEmbedCode($html){
$result=str_replace("?app_id=122963", "?app_id=122963&loop=1&background=1&autoplay=1", $html);
return $result;
}
This works fine but now they want to still be able to embed a video in the WYSIWYG editor and have it retain the standard Vimeo controls and not to autoplay.
Is there a way to make the filter context-aware and only be applied when the_content is NOT being outputted?
本文标签: filtersModify oembed code conditionally
版权声明:本文标题:filters - Modify oembed code conditionally 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749125842a2319765.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论