WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on creating a shortcode to embed locally hosted Quicktime movies, but I can't seem to get the default attributes to stick. Here's what I'm working with, can anyone spot anything obviously wrong? The result gives me no value for an unspecified attribute at all (in this case height/width), rather than the desired defaults of 480 and 320. If specified, it works as intended.

function quicktime_embedder( $atts, $content = null ) {
    extract( shortcode_atts( array(
        'url' => '#',
        'width' => '480',
        'height' => '320'
    ), $atts ) );

    return '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
                codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="300" width="500">
                <param name="src" value="http://www.yoursite.com/video/video1.mov">
                <param name="autoplay" value="false">
                <param name="controller" value="true">
                <param name="type" value="video/quicktime" height="'.$atts[height].'" width="'.$atts[width].'">
                <embed src="'.$atts[url].'"
                     height="'.$atts[height].'" width="'.$atts[width].'" autoplay="false" type="video/quicktime"

add_shortcode( 'quicktime', 'quicktime_embedder' );

share|improve this question
up vote 0 down vote accepted

extract takes and associative array and explodes it out in variables that reflect the array key names. $atts['height'] would just be $height, in other words.

The relevant two lines of your code would become:

<param name="type" value="video/quicktime" height="'.$height.'" width="'.$width.'">
<embed src="'.$url.'" height="'.$height.'" width="'.$width.'" autoplay="false" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/">

If you did still want to use the indexing, make sure you surround array keys with quotes: $atts['height'] not $atts[height]. Replace extract:

$atts = shortcode_atts( array(
        'url' => '#',
        'width' => '480',
        'height' => '320'
    ), $atts )
share|improve this answer
Perfect! I didn't understand extract correctly. That got me exactly what I needed, thank you so much! – Dan G. Aug 29 '11 at 13:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.