oEmbed in Comments

Last week I tried to embed a tweet in a comment reply here, and I was sad when I realized that comments don’t get the same oEmbed magic that posts do. I thought about making a core ticket to add this — and I still may do that eventually — but decided to make it a plugin first.

Over the weekend I wrote it, and earlier today I released oEmbed in Comments on the WordPress.org repository today. It’s also on Github.

It’s really simple. Once activated, if someone posts a comment with a stand-alone URL pointing to an approved oEmbed provider (like YouTube or Twitter) it will grab the media and replace the link with an embed. There’s no UI and no settings, just activate the plugin and it works.

If you search for this kind of thing, you may find an old plugin called oEmbed for Comments (lots of creative naming here). I originally thought I might just use that, but on closer inspection I didn’t like the way the plugin worked. It sort of used WordPress core’s oEmbed functionality, but it also rewrote a significant part of that on its own. On top of that, it hasn’t been updated in two and a half years, which isn’t a good sign.

In the end, I decided I’d be happier with something simpler and done from scratch.

13 thoughts on “oEmbed in Comments

  1. Japh

    I hadn’t realised either that the oEmbed functionality was only for post content and didn’t already extend to comments etc. as well.

    Thanks for solving my problem before I realised I had it :)

    Plugin installed.

    Reply
    1. evan Post author

      Have you considered opening a feature request for this in core trac?

      Funny you should ask…

      I thought about making a core ticket to add this — and I still may do that eventually — but decided to make it a plugin first

      First paragraph of the post

      Reply
  2. Pingback: oEmbed in WordPress Comments — Konstantin Kovshenin

  3. Parker

    Sorry for using your blog, but I don’t have a facebook or anything, and when I left a eply on the plugin page, it wouldn’t post it even though I was logged in. Anyway, I installed buddypig (using all required software versions) and my site crashed. as in, I am not able to view any part of it whatsoever. HELP ME PLEASE

    Reply
    1. evan Post author

      You should probably start by deleting the plugin via FTP or SSH.

      It would be ideal if you could post in the support forum. If you can’t login there for some reason, there’s a temporary placeholder site setup for BuddyPig here.

      Wherever you post next, please try to find more information about what went wrong from your error logs.

      Reply
    1. evan Post author

      I just tested it on WordPress 3.6 and it worked correctly. I did notice one thing it could have done a little better, and pushed an update, which should be available from WordPress.org soon. It’s probably not something that will fix your problem, but you never know.

      There are a couple different ways that comments can be loaded in WordPress, and in particular this plugin does not work with the comments_template() function (codex), which is used in some themes/plugins. If I had to take a total shot in the dark (I’ve never seen the theme you mentioned) I’d guess that’s the issue.

      If you’d like to help improve it, there is an open todo in WordPress core to make comments_template() play nicer with the comments API.

      Reply
        1. evan Post author

          The theme does use comments_template(), so for now this plugin won’t work. Sorry.

          As an aside, upgrading a plugin won’t affect the rest of WordPress core, but you shouldn’t change WordPress core files. Upgrades are important. If you’re not installing them your site is probably vulnerable to known bugs, including security bugs, which have already been fixed.

          Reply
          1. Neo

            But the upgrade not good for me now.

            Why?

            Becouse I’m hungrian and this(ALL) file coded in ANSI.

            I not like transforme all file in UTF8….

            This is a very noing bug..

            Canot modified header erorr messange come up,etc….

            Reply

Leave a Reply