Search

What’s the most elegant way people are adding YouTube videos to their blog posts these days?

For Flickr, Vimeo and YouTube I use a Markdown textarea and include the URL as a paragraph. In XSL I use the razor sharp skills of ninja to transform paragraphs whose text() begins with “http://” and then use a choose/when to see what type of media to write embed tags for.

NIck, does your extension also take care of the flash object embedding? Or does it contains examples of embedding?
It would be nice not having to bother with embedding, when one feels lazy ;-)

Nope ‘fraid not. It’s in the Todo list if anyone fancies forking and implementing it. It provides the URL to the video (the video ID) so embedding is a trivial task.

Nick I assume you use the swfobject static method, because otherwise you’d have to have to dynamically create JS with symphony on your page? All those IE conditionals will be fun to note … ofcourse I could do it without JS

As for ninja, the only http’s I have in p’s are movies so

match="p[substring(text(),1,7)='http://']"  

should do the trick?

How you embed is up to you (JavaScript or not) but yes, I match on the above and inside the matching template I inspect the string and choose how to embed (i.e. write an img tag for Flickr etc).

Thanks for the tips and ideas guys!

I want to avoid conditional comments and needign to generate JS params, so I am simply trying this;

<xsl:template match="p[substring(text(),1,7)='http://']">
<object type="application/x-shockwave-flash" data="{.}"><param name="src" value="{.}" /></object>
</xsl:template>

resulting in the flash object printing, but no movie, rightclik displays; movie not loaded

using safari and FF

any tips?

or cudl this be a mac bug

Perhaps YouTube require specific embedding parameters. Try and replicate their embed HTML and work backwards, deconstructing until you see your current error.

Thanks Nick, that way I have been able to minimise code, just all params as attribute of object. The YT references came in handy.

The probem was I forgat that the uri for the youtube page (the ones authors use, as its most convenient) is not the same as the uri to embed, so a little substring was needed.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details