Does anyone know if I can mark a post if there is a youtube video is included? In my view I only see the first sentences and sometimes there is interesting content like a video or else.

Comments

Tim99’s picture

I use TinyMCE and a youtube-plugin to get the video code into the node. It looks something like that:

<object class="youtube" type="application/x-shockwave-flash" style="width: 425px; height:350px;" data="http://www.youtube.com/v/abcdefgh">
<br />
<param name="movie" value="http://www.youtube.com/v/abcdefgh" />
<param name="wmode" value="transparent" />
<!--<embed src="http://www.youtube.com/v/abcdefgh" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>-->
</object>

Currently I look for a certain string in the content:

if (substr_count($content, "http://www.youtube.com/v")>=1) {
   echo "<span class="includes_youtube floatright">&nbsp;</span>";
}

But unfortunately this only works when the full node is displayed. Not in the teaser view (if the video is outside the teaser). Any ideas how to overcome that drawback? What should I scan instead of the $object variable?

I already tried:

if (substr_count($content, "http://www.youtube.com/v")>=1)
if (substr_count($node->body, "http://www.youtube.com/v")>=1)
if (substr_count($node->body['content'], "http://www.youtube.com/v")>=1)
if (substr_count($node->body['view'], "http://www.youtube.com/v")>=1)

1-3 doesn't show anything. 4 only works as described above. When I use dprint_r($node) in the teaser view, there is nothing about the included video unfortunately. Any ideas?