最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

filters - Modify oembed code conditionally

matteradmin9PV0评论

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?

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far