Adding valid video code to WordPress sidebar

11:14 in wordpress by Ron

If you are validating your webpage but have embedded video from YouTube or most other video sites, chances are your page will not validate via the WC3 Validator.

Not to worry, whether you are adding a video to your sidebar or to a post or page, do the following:

Grab your “embed” code. It will look something like this:

< 'object width="425" height="344" '>
< 'param name="movie" value="http://www.youtube.com/v/PObIJN17iNs&hl=en&fs=1">
< 'param name="allowFullScreen" value="true" '>< '/param '>
< 'param name="allowscriptaccess" value="always" '>< '/param'>
< 'embed src="http://www.youtube.com/v/PObIJN17iNs&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344" '>< '/embed ' >
< '/'object>

Note that the actual URL or Link to the video is here:

http://www.youtube.com/v/PObIJN17iNs

the additional stuff starting with the & is not needed, in the case above, the &hl=en&fs=1

To embed this in your sidebar or page and have it validate and be somewhat shorter, all you need is the following:

<object class="aligncenter" width="425" height="344" type="application/x-shockwave-flash" data="http://www.youtube.com/v/gZ9sM8Lu4ug">
<param name="movie" value="http://www.youtube.com/v/gZ9sM8Lu4ug" />
<param name="allowfullscreen" value="true" />
<param name="wmode" value="transparent" />
</object>

The result is video which also validates.

(The class=”aligncenter” simply puts it in the center of the page, but you need to have a “aligncenter” defined in your CSS stylesheet somewhere to have that work.)

  • Share/Bookmark