<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
		>
	<channel>
		<title>Wordpress and Webdesign Forum go41 &#187; Tag: oembed - Recent Posts</title>
		<link>http://forum.go41.de/tags/oembed</link>
		<description>How To, tips, php and css code for your WordPress site</description>
		<language>en-US</language>
		<pubDate>Thu, 09 Feb 2012 18:07:15 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
				<atom:link href="http://forum.go41.de/rss/tags/oembed" rel="self" type="application/rss+xml" />

		<item>
			<title>Joern on "add latest video from a post in WordPress sidebar"</title>
			<link>http://forum.go41.de/topic/add-latest-video-from-a-post-in-wordpress-sidebar#post-838</link>
			<pubDate>Wed, 16 Feb 2011 15:54:19 +0000</pubDate>
			<dc:creator>Joern</dc:creator>
			<guid isPermaLink="false">838@http://forum.go41.de/</guid>
			<description><![CDATA[<p>An addition:<br />
Here we take an embeded video from a post in a certain category. The code above in sidebarclip.php loads by default only one latest post. You can however change:<br />
query_posts('posts_per_page=1&#38;cat=$category_id');<br />
to load let's say 4 posts where each has another video embeded:<br />
query_posts('posts_per_page=4&#38;cat=$category_id');<br />
now you load 4 players.</p>
<p>The size of the player you can set in sidebarclip.php:<br />
	'width'=&#62;300,<br />
	'height'=&#62;250 ));<br />
to another value<br />
use style.css to arrange that players as you like - first you have to get them to show up..
</p>]]></description>
					</item>
		<item>
			<title>Joern on "add latest video from a post in WordPress sidebar"</title>
			<link>http://forum.go41.de/topic/add-latest-video-from-a-post-in-wordpress-sidebar#post-834</link>
			<pubDate>Tue, 15 Feb 2011 12:36:40 +0000</pubDate>
			<dc:creator>Joern</dc:creator>
			<guid isPermaLink="false">834@http://forum.go41.de/</guid>
			<description><![CDATA[<p>I am going to add a video to the sidebar. This video is taken from the last post in a category you have to set.</p>
<p>The post actually is filtered for an oembed video, only this video will be displayed in a size you can set.</p>
<p>For testing I just do it on a theme demo site here:<br />
<a href="http://themes.go41.de/?wptheme=arthemix_dev" rel="nofollow">http://themes.go41.de/?wptheme=arthemix_dev</a></p>
<p>First of all you should have a post with an embeded video, WordPress allows you to embed a video by just inserting the URL in a single line in the post editor, like this:</p>
<pre><code><a href="http://www.youtube.com/watch?v=wLph9-ZkMX8" rel="nofollow">http://www.youtube.com/watch?v=wLph9-ZkMX8</a></code></pre>
<p>looking at the single post it should show you the video.</p>
<p>Let's do it (sample should be to see here <a href="http://themes.go41.de/?wptheme=arthemix_dev" rel="nofollow">http://themes.go41.de/?wptheme=arthemix_dev</a> )</p>
<p>STOP: BACKUP YOUR FILES WE ARE GOING TO CHANGE, just in case...</p>
<p>We have to edit sidebar.php and add two lines to load another template called sidebarclip.php (we will create this file later)</p>
<p>Lines to add in sidebar.php: (in Arthemia under div id="sidebar" just above div id="sidebar-ads" )</p>
<pre><code>&#60;?php if(file_exists(TEMPLATEPATH . &#39;/sidebarclip.php&#39;)) { // get the clip-script
	include (TEMPLATEPATH . &#39;/sidebarclip.php&#39;); } ?&#62;</code></pre>
<p>This code just looks for the following template file in your themes folder, It's just a 'manual widget' ;-) </p>
<p>Create a new file called sidebarclip.php with the following content</p>
<pre><code>&#60;div id=&#34;sidebar-video&#34;&#62;
&#60;?php $category_id = get_cat_ID( &#39;Videos&#39; ); // set your category name here, if you know the ID use $category_id = 6;  ?&#62;
&#60;h3&#62;Featured Video &#60;a style=&#34;float: right;&#34; href=&#34;&#60;?php $category_link = get_category_link( $category_id ); echo $category_link; ?&#62;&#34; title=&#34;more Videos&#34;&#62;more Videos&#60;/a&#62;&#60;/h3&#62;
&#60;?php
query_posts(&#39;posts_per_page=1&#38;cat=$category_id&#39;);
if ( have_posts() ) : while ( have_posts() ) : the_post();?&#62;
&#60;?php if((function_exists(&#39;resizeMarkup&#39;)) &#38;&#38; (function_exists(&#39;get_embedhtml&#39;))) {
	$resizedvideo = resizeMarkup((get_embedhtml($postID)), array(
	&#39;width&#39;=&#62;300,
	&#39;height&#39;=&#62;250 ));
	if($resizedvideo != &#39;&#39;)
			{
			echo $resizedvideo;
			} else { // if no Video
			echo &#39;no Clip available&#39;;
			}
		} ?&#62;
&#60;p&#62;Read the post:&#60;br /&#62;&#60;a href=&#34;&#60;?php the_permalink() ?&#62;&#34; title=&#34;&#60;?php the_title(); ?&#62;&#34;&#62;&#60;?php the_title(); ?&#62;&#60;/a&#62;&#60;/p&#62;

&#60;?php
endwhile;endif;
wp_reset_query();
?&#62;
&#60;/div&#62;</code></pre>
<p>beeing here I can see something new in the sidebar already, but where is the video clip?<br />
We still have to add some functions in functions.php of your theme folder, here the script: you should add it at the end of functions.php before the closing '?&#62;'<br />
<pre><code>// the function to resize oembed videos
function resizeMarkup($markup, $dimensions)
{
$w = $dimensions[&#39;width&#39;];
$h = $dimensions[&#39;height&#39;];

$patterns = array();
$replacements = array();
if( !empty($w) )
{
$patterns[] = &#39;/width=&#34;([0-9]+)&#34;/&#39;;
$patterns[] = &#39;/width:([0-9]+)/&#39;;

$replacements[] = &#39;width=&#34;&#39;.$w.&#39;&#34;&#39;;
$replacements[] = &#39;width:&#39;.$w;
}

if( !empty($h) )
{
$patterns[] = &#39;/height=&#34;([0-9]+)&#34;/&#39;;
$patterns[] = &#39;/height:([0-9]+)/&#39;;

$replacements[] = &#39;height=&#34;&#39;.$h.&#39;&#34;&#39;;
$replacements[] = &#39;height:&#39;.$h;
}

$patterns[] = &#39;/&#60;\/param&#62;&#60;embed/&#39;;
$patterns[] = &#39;/allowscriptaccess=&#34;always&#34;/&#39;;

$replacements[] = &#39;&#60;/param&#62;&#60;param name=&#34;wmode&#34; value=&#34;transparent&#34;&#62;&#60;/param&#62;&#60;embed&#39;;
$replacements[] = &#39;wmode=&#34;transparent&#34; allowscriptaccess=&#34;always&#34;&#39;;

return preg_replace($patterns, $replacements, $markup);
}

// get_embedhtml
function get_embedhtml($postID)
{
  $custom_field_keys = get_post_custom_keys();
  foreach ( $custom_field_keys as $key =&#62; $value ) {
    $valuet = trim(substr($value, 1, 4));
	if ( &#39;oemb&#39; == $valuet ) { // look if a oembed key exists
    $oembkey = $value; //now set the the key we found as oembkey
	$oembvalue = get_post_custom_values($oembkey); //get the value of oembkey as oembvalue
	if (isset($oembvalue[0])) {
		$embedhtml = ($oembvalue[0]);
return $embedhtml;
		}
	}
  }

}

function add_transparent($oembvideo) {
$patterns = array();
$replacements = array();
$patterns[] = &#39;/&#60;\/param&#62;&#60;embed/&#39;;
$patterns[] = &#39;/allowscriptaccess=&#34;always&#34;/&#39;;

$replacements[] = &#39;&#60;/param&#62;&#60;param name=&#34;wmode&#34; value=&#34;transparent&#34;&#62;&#60;/param&#62;&#60;embed&#39;;
$replacements[] = &#39;wmode=&#34;transparent&#34; allowscriptaccess=&#34;always&#34;&#39;;

return preg_replace($patterns, $replacements, $oembvideo);

	return $oembvideo;
}
add_filter(&#39;embed_oembed_html&#39;, &#39;add_transparent&#39;);</code></pre>
<p>Works! Lucky we are, but still could apply some styling to the new div id="sidebar-video" to make it look nice.</p>
<p>This is done in style.css, I use:</p>
<p>#sidebar-video {<br />
width:300px;<br />
float:right;<br />
border:1px solid #DDDDDD;<br />
background:#FFFFFF;<br />
padding:10px 9px;<br />
margin: 0 0 10px;<br />
}</p>
<p>Try it, having problems ask for help!<br />
Demo here: <a href="http://themes.go41.de/?wptheme=arthemix_dev" rel="nofollow">http://themes.go41.de/?wptheme=arthemix_dev</a> in the sidebar
</p>]]></description>
					</item>
		<item>
			<title>s0206 on "add_filter to embed_oembed_html to get wmode transparent"</title>
			<link>http://forum.go41.de/topic/add_filter-to-embed_oembed_html-to-get-wmode-transparent#post-617</link>
			<pubDate>Sat, 21 Aug 2010 23:55:35 +0000</pubDate>
			<dc:creator>s0206</dc:creator>
			<guid isPermaLink="false">617@http://forum.go41.de/</guid>
			<description><![CDATA[<p>Thank you very much!</p>
<p>I was embedding the code form youtube rather than just using a plain url. This works great.</p>
<p>Thanks once again!</p>
<p>:-)
</p>]]></description>
					</item>
		<item>
			<title>masteradmin on "add_filter to embed_oembed_html to get wmode transparent"</title>
			<link>http://forum.go41.de/topic/add_filter-to-embed_oembed_html-to-get-wmode-transparent#post-615</link>
			<pubDate>Sat, 21 Aug 2010 22:22:21 +0000</pubDate>
			<dc:creator>masteradmin</dc:creator>
			<guid isPermaLink="false">615@http://forum.go41.de/</guid>
			<description><![CDATA[<p>Using WordPress 3.0.1 I just copied the source code of FireFox. For an embeded video the code looks like this with the function above in functions.php<br />
<pre><code>&#60;object width=&#34;450&#34; height=&#34;363&#34;&#62;
&#60;param name=&#34;movie&#34; value=&#34;http://www.youtube.com/v/wLph9-ZkMX8&#38;fs=1&#34;&#62;&#60;/param&#62;
&#60;param name=&#34;allowFullScreen&#34; value=&#34;true&#34;&#62;&#60;/param&#62;
&#60;param name=&#34;allowscriptaccess&#34; value=&#34;always&#34;&#62;&#60;/param&#62;
&#60;param name=&#34;wmode&#34; value=&#34;transparent&#34;&#62;&#60;/param&#62;
&#60;embed src=&#34;http://www.youtube.com/v/wLph9-ZkMX8&#38;fs=1&#34; type=&#34;application/x-shockwave-flash&#34; width=&#34;450&#34; height=&#34;363&#34; wmode=&#34;transparent&#34; allowscriptaccess=&#34;always&#34; allowfullscreen=&#34;true&#34;&#62;&#60;/embed&#62;
&#60;/object&#62;</code></pre>
<p>removed the function it comes out like this<br />
<pre><code>&#60;object width=&#34;450&#34; height=&#34;363&#34;&#62;
&#60;param name=&#34;movie&#34; value=&#34;http://www.youtube.com/v/wLph9-ZkMX8&#38;fs=1&#34;&#62;&#60;/param&#62;
&#60;param name=&#34;allowFullScreen&#34; value=&#34;true&#34;&#62;&#60;/param&#62;
&#60;param name=&#34;allowscriptaccess&#34; value=&#34;always&#34;&#62;&#60;/param&#62;
&#60;embed src=&#34;http://www.youtube.com/v/wLph9-ZkMX8&#38;fs=1&#34; type=&#34;application/x-shockwave-flash&#34; width=&#34;450&#34; height=&#34;363&#34; allowscriptaccess=&#34;always&#34; allowfullscreen=&#34;true&#34;&#62;&#60;/embed&#62;
&#60;/object&#62;</code></pre>
<p>See the difference in source code?</p>
<p>On screen you will not see any difference except the movie covered an unfolding menu and stayed above items it should not cover.</p>
<p>This video above is just a plain URL link to a YouTube Video in a post, sample:<br />
go to <a href="http://themes.go41.de/?wptheme=Barthami_Corporate" rel="nofollow">http://themes.go41.de/?wptheme=Barthami_Corporate</a> first to get a theme with this function enabled and than open this post: <a href="http://themes.go41.de/2009/12/22/wordpress-2-9-is-using-automatically-embed-of-plain-text-url-videos/" rel="nofollow">http://themes.go41.de/2009/12/22/wordpress-2-9-is-using-automatically-embed-of-plain-text-url-videos/</a>
</p>]]></description>
					</item>
		<item>
			<title>s0206 on "add_filter to embed_oembed_html to get wmode transparent"</title>
			<link>http://forum.go41.de/topic/add_filter-to-embed_oembed_html-to-get-wmode-transparent#post-613</link>
			<pubDate>Sat, 21 Aug 2010 16:19:02 +0000</pubDate>
			<dc:creator>s0206</dc:creator>
			<guid isPermaLink="false">613@http://forum.go41.de/</guid>
			<description><![CDATA[<p>Hi there</p>
<p>I tried adding this to my functions file but it made no difference whatsoever. I am using wordpress 3.0.</p>
<p>Any idea's on how to get it working?</p>
<p>Thanks in advance
</p>]]></description>
					</item>
		<item>
			<title>masteradmin on "add_filter to embed_oembed_html to get wmode transparent"</title>
			<link>http://forum.go41.de/topic/add_filter-to-embed_oembed_html-to-get-wmode-transparent#post-104</link>
			<pubDate>Thu, 24 Dec 2009 11:19:24 +0000</pubDate>
			<dc:creator>masteradmin</dc:creator>
			<guid isPermaLink="false">104@http://forum.go41.de/</guid>
			<description><![CDATA[<p>The video embedded by WordPress 2.9 hasn't the parameters &#60;param name='wmode' value='transparent' /&#62; and &#60;embed wmode="transparent" ... &#62;.<br />
This makes it stay above a dropdown menu and any other elements on the<br />
page. Yes, it is possible to modify the code returned by oEmbed for flash videos!<br />
You have to use the add_filter function of Wordpress to modify the embed_oembed_html.</p>
<p>The code below filters the embed code stored by WordPress in the database. Tis code just inserts &#60;param name="wmode" value="transparent"&#62;&#60;/param&#62; and wmode="transparent" in the required places.</p>
<p>Create a file functions.php or use the one in your themes folder if there is. Put the code given below before the closing '?&#62;' at the end of this file. As soon this code is in place, it should filter the video object and embed code. The problem of a dissappearing menu should be gone!</p>
<p>The code snippet for your theme's functions.php:</p>
<pre><code>function add_transparent($oembvideo) {
$patterns = array();
$replacements = array();
$patterns[] = &#39;/&#60;\/param&#62;&#60;embed/&#39;;
$patterns[] = &#39;/allowscriptaccess=&#34;always&#34;/&#39;;

$replacements[] = &#39;&#60;/param&#62;&#60;param name=&#34;wmode&#34; value=&#34;transparent&#34;&#62;&#60;/param&#62;&#60;embed&#39;;
$replacements[] = &#39;wmode=&#34;transparent&#34; allowscriptaccess=&#34;always&#34;&#39;;

return preg_replace($patterns, $replacements, $oembvideo);

	return $oembvideo;
}
add_filter(&#39;embed_oembed_html&#39;, &#39;add_transparent&#39;);</code></pre>
<p>please BACKUP original files to be able to step back!!
</p>]]></description>
					</item>
		<item>
			<title>masteradmin on "Change width and height in oembed code on the fly WP 2.9"</title>
			<link>http://forum.go41.de/topic/change-width-and-height-in-oembed-code-on-the-fly-wp-29#post-102</link>
			<pubDate>Mon, 21 Dec 2009 14:41:07 +0000</pubDate>
			<dc:creator>masteradmin</dc:creator>
			<guid isPermaLink="false">102@http://forum.go41.de/</guid>
			<description><![CDATA[<p>As explained in a previous topic <a href="http://forum.go41.de/topic/get-the-oembed-code-of-a-video-in-a-wp-29-post-from-postmeta">get the oembed code of a video in a WP 2.9 post from postmeta</a> we can get only the code for embeded media (WordPress 2.9 required!)</p>
<p>To change and resize the width and height of the video we are going to display, we can add a function to the theme's function.php to do this for us.<br />
I got this function from Vinod Kumar explained here:<br />
<a href="http://scvinodkumar.wordpress.com/2009/08/14/dynamically-change-width-and-height-in-embed-code/">Dynamically Change Width and Height in embed code</a></p>
<p>So put this function into your functions.php first:<br />
<pre><code>// the function to resize oembed videos
function resizeMarkup($markup, $dimensions)
{
$w = $dimensions[&#39;width&#39;];
$h = $dimensions[&#39;height&#39;];

$patterns = array();
$replacements = array();
if( !empty($w) )
{
$patterns[] = &#39;/width=&#34;([0-9]+)&#34;/&#39;;
$patterns[] = &#39;/width:([0-9]+)/&#39;;

$replacements[] = &#39;width=&#34;&#39;.$w.&#39;&#34;&#39;;
$replacements[] = &#39;width:&#39;.$w;
}

if( !empty($h) )
{
$patterns[] = &#39;/height=&#34;([0-9]+)&#34;/&#39;;
$patterns[] = &#39;/height:([0-9]+)/&#39;;

$replacements[] = &#39;height=&#34;&#39;.$h.&#39;&#34;&#39;;
$replacements[] = &#39;height:&#39;.$h;
}

return preg_replace($patterns, $replacements, $markup);
}</code></pre>
<p>Having this code activated by putting it in functions.php, we can use it as explained in Vinod's post (link above).</p>
<p>We want to use this function to change width and height attributes throughout the oembed code we retrieved before from the WordPress database.<br />
As explained here: <a href="http://forum.go41.de/topic/get-the-oembed-code-of-a-video-in-a-wp-29-post-from-postmeta" rel="nofollow">http://forum.go41.de/topic/get-the-oembed-code-of-a-video-in-a-wp-29-post-from-postmeta</a> we have already a variable assigned to the oembed code, now we just pass this variable to the function 'resizeMarkup' with new values for width and height and echo the resized video clip.<br />
To do this we put into the loop this code:<br />
<pre><code>&#60;?php if(function_exists(&#39;resizeMarkup&#39;)) {
	$resizedvideo = resizeMarkup(($embedhtml), array(
	&#39;width&#39;=&#62;300,
	&#39;height&#39;=&#62;250 ));
	echo $resizedvideo; } ?&#62;</code></pre>
<p>Any questions? Sign up and ask, you are welcome.
</p>]]></description>
					</item>
		<item>
			<title>masteradmin on "get the oembed code of a video in a WP 2.9 post from postmeta"</title>
			<link>http://forum.go41.de/topic/get-the-oembed-code-of-a-video-in-a-wp-29-post-from-postmeta#post-101</link>
			<pubDate>Mon, 21 Dec 2009 14:19:51 +0000</pubDate>
			<dc:creator>masteradmin</dc:creator>
			<guid isPermaLink="false">101@http://forum.go41.de/</guid>
			<description><![CDATA[<p>The latest WordPress 2.9 got a new function to automatically embed all plain text URLs with the help of oembed. On a blog displaying resized images together with the_excerpt it is nice to show also the embeded video clips if there is no image.<br />
So how to get the code to embed a video from the database?<br />
In WordPress 2.9, if you insert a plain URL link to a video from an oembed enabled site, WordPress will try to put the whole code around this URL to embed this video in a player.<br />
This code will not show up in edit posts, but is written to postmeta table. The meta_key is looking like '_oembed_74dd854eb13572c16.....' and it's meta_value is the actually html code to get parsed.</p>
<p>Working inside the loop, we are going to get the unique meta_key of a post starting with oembed. If in a post is this meta_key we assign this to a variable (here: $oembkey)<br />
Next we get the value of this key, which is actually the full html embed code (here: $embedhtml)</p>
<p>Finally we can echo $embedhtml to display only the video without the_content or the_excerpt.</p>
<p>The code to get only the embeded video:</p>
<pre><code>&#60;?php
  $custom_field_keys = get_post_custom_keys();
  foreach ( $custom_field_keys as $key =&#62; $value ) {
    $valuet = trim(substr($value, 1, 4));
	if ( &#39;oemb&#39; == $valuet ) { // look if a oembed key exists
    $oembkey = $value; //now set the the key we found as oembkey
	$oembvalue = get_post_custom_values($oembkey); //get the value of oembkey as oembvalue
	if (isset($oembvalue[0])) {
		$embedhtml = ($oembvalue[0]);
	  }
	}
  }
?&#62;</code></pre>
<p>and now echo it:</p>
<pre><code>&#60;?php echo $embedhtml; ?&#62;</code></pre>
<p>In another topic I will explain how to resize this player here:<br />
<a href="http://forum.go41.de/topic/change-width-and-height-in-oembed-code-on-the-fly-wp-29">Change width and height in oembed code on the fly WP 2.9</a>
</p>]]></description>
					</item>

	</channel>
</rss>

