jQuery Flash Plugin - Inline Params Example

« Back to the jQuery flash plugin

Javascript:

$(document).ready(function(){
    $('li').flash(null, { version: 8 }, function(htmlOptions) {
        var $this = $(this);
        var params = $this.attr('rel').split(':');
        htmlOptions.src = params[0];
        htmlOptions.width = params[1];
        htmlOptions.height = params[2];
        this.innerHTML = '<div class="alt">'+this.innerHTML+'</div>';
        $this.addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions));
    });
});

Before:

<ul id="example">
    <li rel="example.swf:160:105">Small</li>
    <li rel="example.swf:320:215">Medium</li>
    <li rel="example.swf:720:480">Large</li>
</ul>

After:

<ul id="example">
    <li rel="example.swf:160:105" class="flash-replaced">
        <embed width="160" height="105" type="application/x-shockwave-flash" src="example.swf" pluginspage="http://www.adobe.com/go/getflashplayer" flashvars=""/>
        <div class="alt">Small</div>
    </li>
    <li rel="example.swf:320:215" class="flash-replaced">
        <embed width="320" height="215" type="application/x-shockwave-flash" src="example.swf" pluginspage="http://www.adobe.com/go/getflashplayer" flashvars=""/>
        <div class="alt">Medium</div>
    </li>
    <li rel="example.swf:720:480" class="flash-replaced">
        <embed width="720" height="480" type="application/x-shockwave-flash" src="example.swf" pluginspage="http://www.adobe.com/go/getflashplayer" flashvars=""/>
        <div class="alt">Large</div>
    </li>
</ul>