So I have a helper that I’m using to swap my header image for another image that seems to work fine. This is my helper.
def header_image_tag
@header_image ||= 'headers/image.png'
image_tag @header_image
end
def header_image(image_path)
@header_image = image_path
end
And in my View I use.
<% header_image('headers/newimage.png') %>
Now here is the tricky part, what I’d like to do, is instead of replacing it with a picture I’d like to swap in a flash banner.
I tried to do it by swapping in code instead using sanitize (which works just not using object tags). Below is first my helper for this…
def text_banner_tag
@text_banner ||= 'textBanner.png'
if @text_banner != "textBanner.png"
else
image_tag @text_banner
end
end
def text_banner(object_code)
@text_banner = object_code
end
and the code in my view…
<% text_banner(sanitize('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="970" height="48" id="FlashID" title="textbanner" alt="text banner">
<param name="movie" value="/flash/textbanner.swf">
<param name="quality" value="high">
<param name="wmode" value="transparent">
<param name="swfversion" value="6.0.65.0">
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="/flash/textbanner.swf" width="970" height="48">
<!--<![endif]-->
<param name="quality" value="high">
<param name="wmode" value="transparent">
<param name="swfversion" value="6.0.65.0">
<param name="expressinstall" value="/Scripts/expressInstall.swf">
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<div>
<%= image_tag("textBanner.png", :size => "970x48", :alt => "text banner", :border => "0") %>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>')) %>
Any and all help would be greatly appreciated!
In doing some digging around, for those that might come across this in the future and want to implement it on their own site, this is what I found and works great.
Basically you need to ad a set of tags and a set of attributes to the sanitize as sanitize only uses basic html its missing things like which are much needed elements for flash.
Here’s what I did in the helper:
In the layout you call the banner using:
And in the view that you’d like to display the flash banner for you add this to the top of the view:
be sure to fill in everything you need for the flash object.
You can also use this to implement lots of other extras
Security Warning just be careful if your handing this usage out to users that are filling in forms that allow for code.