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

	</channel>
</rss>

