How can I replace an oEmbed URL in post with actual embed HTML

What I want is to get the output of the Twitter oEmbed system into my actual posts. IMHO the embed output itself is high-quality, semantic HTML and I’d rather have it inside the post than in the embed metadata in case their js stops working (in which case the tweet would display as a sensible blockquote).

So what I need is to hijack the oEmbed system and, upon processing it, replace the embed URL in the post with the HTML from Twitter. Clearly the solution should also be able to handle other kinds of embeds.

Read More

UPDATE: Just to be clear, I know how oEmbed works by default (i.e. the URL will be replaced with the oEmbed HTML when the ‘the_content’ filter is run on the post content) and that is not what I want. What I need is a way to hijack that system and, instead of only having the content replaced at display time, have the embed URL itself replaced inside the post_content in the the database with the HTML returned from the oEmbed provider.

Related posts

2 comments

  1. This will be copyright violation and it is very not recommended to do from a legal perspective.

    From a technical perspective, embeded code many times uses “external” resources like JS and CSS that might load in the context of an iframe but not in the context of your site.

    So, it is both a legal and technical mine field which you probably should not even attempt to step in.

Comments are closed.