Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Additional params for uploaded flash

Go to End

23 Posts   5847 Views


Community Member, 42 Posts

20 November 2009 at 10:06am

Edited: 20/11/2009 11:59am

Is there a way to add additional default parameters, such as wMode: transparent, to the content flash upload?

Edit: Sorry for the lame way of asking, but I am in 2.3.3 and need to add the "wMode: transparent" to all flash files uploaded through the HTML editor for a page content region. Any help?



Community Member, 283 Posts

26 November 2009 at 4:52am

Do you mean for the corresponding embed, or do you want to store a wMode attribute with the file metadata to be used later?


Community Member, 42 Posts

26 November 2009 at 8:15am

Thanks for responding, dalesaurus. And, please forgive my density if I'm not answering the question correctly.

I need all flash files uploaded through the content area of the CMS to have the wMode: transparent attribute associated with the corresponding embed.

The following is what shows in source by default:

<object height="342" width="613" type="application/x-shockwave-flash" data="assets/Flash/dMap_v6_aa.swf">
<param value="assets/Flash/dMap_v6_aa.swf" name="src"/>

If I upload through a custom field, I know I can code it within the layout (or, at least I think I can). But, I didn't want to go that way (adding any additional fields in the CMS for this) if I could just modify what's already in place.

It may sound silly, but is there a way to deal with this through CSS?

Does this make sense? (I'm fighting some kind of ick at the moment and don't trust my powers of communication.)


Community Member, 283 Posts

26 November 2009 at 11:28am

I see what you're up to and it does make sense. However without digging in the code I don't think there is a way to change the embed without hacking some core files. You can do that OR be really lazy and hammer at it with jQuery.


Community Member, 904 Posts

26 November 2009 at 8:27pm

Edited: 26/11/2009 8:27pm

Hi AlaVive

I think it would be best to separate the flash content in a file upload field and then use SWFObject to embed the flash. This approach has several advantages:
- You can freely customize all the flash embed parameters and more
- SWFObject automatically detects if the required flash player is installed and can otherwise display alternative content
- It generates valid HTML

The jQuery hack proposed by dalesaurus could be another option, but I'm not sure if it will work. My guess is, that the Flash Player Object only checks the wmode parameter at initialization. Now if that happens before jQuery runs, you're out of luck. But it's probably worth a try.

Personally, I would choose the SWFObject route and even add a text-field along the file upload field to my page, so that I could provide some alternative text for that flash content (for google, and all the users that don't have flash installed).
If that sounds like a good idea to you, I'd be happy to provide you with a code example.


Community Member, 42 Posts

27 November 2009 at 4:13am

Thanks again for your thoughts, dalesaurus.

Banal, thank you, as well, for your points. You've convinced me. So, if you still don't mind sharing, I am interested in seeing a code example you offered!


Community Member, 904 Posts

27 November 2009 at 5:47am

Sure thing.

- Download and unpack swfobject 2.2 from
- copy swfobject.js and expressInstall.swf from the swfobject folder to your mysite folder. I copied the files into mysite/javascript/lib, so this is what I'm gonna use in this example

I suggest to create a special Page class for our needs. Let's call it "FlashPage". Copy the following code to a file named FlashPage.php in mysite/code:

class FlashPage extends Page 
	public static $db = array(
		'AlternateContent' => 'HTMLText'
	public static $has_one = array(
		'FlashFile'	=> 'File'
	public function getCMSFields(){
		$fields = parent::getCMSFields();
		// create a file upload field that only allows swf to be uploaded
		$fileUpload = new FileIFrameField('FlashFile', 'Flash file (swf)');
		$fields->addFieldsToTab('Root.Content.Flash', array(
			new HtmlEditorField('AlternateContent', 'Flash replacement text', 20)
		return $fields;

class FlashPage_Controller extends Page_Controller
	public function init(){
		// require SWF Object script

After doing this, run dev/build

The FlashPage class has a FlashFile and an alternative content that will show if the flash player isn't installed on the visitors machine. I added these two fields to a new Tab called "Flash" on the same level as "Main".

Now you only need a template for the FlashFile page. This could be either a layout or a full page template. Here's the important template code:

<% if FlashFile %>
<div id="FlashContainer">
<script type="text/javascript">
/* <![CDATA[ */
	"400", "300", 
	{ 'bgcolor' : '#000000', 'wmode' : 'transparent' }
/* ]]> */
<% end_if %>

Here's a short summary what we do here:
First we check if there's a FlashFile available (<% if FlashFile %>). If not, we can skip the whole flash embed stuff.
The <div id="FlashContainer"> container holds the alternative content, and will be replaced with the flash content if the user has the required flash plugin installed.
What follows at the end is the script call to swfobject. There's a good description of these parameters on the SWFObject website:
The wmode can be set with the params argument as I did in the example (I also set the background color).

Let me know if that works :)


Community Member, 119 Posts

28 November 2009 at 12:55am

Banal: Might be worth chucking this up on :)

Go to Top