<?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: postmeta - Recent Posts</title>
		<link>http://forum.go41.de/tags/postmeta</link>
		<description>How To, tips, php and css code for your WordPress site</description>
		<language>en-US</language>
		<pubDate>Thu, 09 Feb 2012 18:46:51 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
				<atom:link href="http://forum.go41.de/rss/tags/postmeta" rel="self" type="application/rss+xml" />

		<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>

