<?xml version="1.0" encoding="UTF-8"?>
<biz/products>
  <biz/product>
    <brand></brand>
    <business-id type="integer">77</business-id>
    <colors></colors>
    <grouping-id type="integer"></grouping-id>
    <id type="integer">88</id>
    <long-description>&lt;p&gt;Anouncement originally posted on &lt;a href="http://hackd.wordpress.com/2007/11/23/sexy-time-zones-in-ruby-on-rails-with-timezone_fu/"&gt;hack'd&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Working with Timezones in Rails even after you have installed the &lt;a href="http://tzinfo.rubyforge.org/" title="TZInfo"&gt;TZInfo&lt;/a&gt; plugin is still a pain in the you know what.  (You are using TZInfo, right?) I never liked having to jump through hoops converting from UTC to localtime when displaying times to Users. I suppose I could have used Javascript to do the conversion but I prefer to deal with the conversion on the back end. &lt;/p&gt;&lt;p&gt;Adding support for time zones to our apps wasn&amp;rsquo;t very fun. While adding timezones to another model model for the third or forth time I decided there had to be a better way. I pointed my browser to the &lt;a href="http://agilewebdevelopment.com/plugins"&gt;agile web development plug in&lt;/a&gt; site and did a quick search. I found a couple plug-ins that helped with timezones or helped with date time pickers; but nothing that did quite what I wanted.&lt;span&gt;&lt;/span&gt;Ideally I wanted a plugin similar to &lt;a href="http://agilewebdevelopment.com/plugins/attachment_fu"&gt;attachment_fu&lt;/a&gt;. I wanted to specify within a model a single method that handled all of the setup. So when I accessed a datetime field the local time would be returned. I also wanted to be able to set the field to local time and have that value converted to UTC before being saved to the database. And the plugin had to do all of this with minimal setup and effort on the part of the developer. Not finding anything that satisfied my requirements I decided to write something. After an hour or two I put together something that I think is worth sharing. Included at the bottom of this post are links to grab the plug-in.&lt;/p&gt; &lt;p&gt;While building &lt;a href="http://www.thrivesmart.com/sprout"&gt;ThriveSmart Sprout!&lt;/a&gt; we used plugins from various developers. The availability of plugins was on the the great strengths of the Rails comunity. In honor of &lt;a href="http://techno-weenie.net/"&gt;techno weenie&lt;/a&gt; and the &lt;a href="http://agilewebdevelopment.com/plugins/attachment_fu"&gt;attachment_fu&lt;/a&gt; plug-in our plug-in was christened timezone_fu.&lt;/p&gt; &lt;p&gt;Timezone_fu makes it really easy to deal with datetime fields in your models. It adds a method to your models has_timezone that takes a hash of options. the README for the plugin describes all of the options but below is an example:&lt;/p&gt; &lt;pre style="border: 1px solid #eeeeee"&gt;  &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;/span&gt; Event &lt;span style="color: #990000"&gt;&amp;lt;&lt;/span&gt; ActiveRecord&lt;span style="color: #990000"&gt;::&lt;/span&gt;Base&lt;br /&gt;    has_timezone &lt;span style="color: #990000"&gt;:&lt;/span&gt;fields &lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color: #990000"&gt;[&lt;/span&gt; &lt;span style="color: #990000"&gt;:&lt;/span&gt;start_datetime&lt;span style="color: #990000"&gt;,&lt;/span&gt; &lt;span style="color: #990000"&gt;:&lt;/span&gt;end_datetime&lt;span style="color: #990000"&gt;]&lt;/span&gt; &lt;span style="color: #990000"&gt;&lt;/span&gt;  &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt; &lt;p&gt;Our Event model has three fields a start_datetime and end_datetime and a timezone. Adding has_timezone to the model changes the behavior of the two datetime attributes.&lt;br /&gt; Notice below that calling event.start_datetime shows the time in local time (&amp;rdquo;America/New York&amp;rdquo;).&lt;/p&gt; &lt;pre style="border: 1px solid #eeeeee"&gt;&lt;span style="color: #990000"&gt;&amp;gt;&amp;gt;&lt;/span&gt; event &lt;span style="color: #990000"&gt;=&lt;/span&gt; Event&lt;span style="color: #990000"&gt;.&lt;/span&gt;find&lt;span style="color: #990000"&gt;(:&lt;/span&gt;first&lt;span style="color: #990000"&gt;)&lt;/span&gt;&lt;span style="color: #990000"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="font-style: italic"&gt;&lt;span style="color: #9a1900"&gt;#&amp;lt;Event:0&amp;times;1b71b40 @attributes={&lt;br /&gt;      &amp;ldquo;end_datetime&amp;rdquo;   =&amp;gt; &amp;ldquo;2007-11-21 15:00:00&amp;Prime;,&lt;br /&gt;      &amp;ldquo;start_datetime&amp;rdquo; =&amp;gt; &amp;ldquo;2007-11-21 14:15:00&amp;Prime;,&lt;br /&gt;      &amp;ldquo;timezone&amp;rdquo;       =&amp;gt; &amp;ldquo;America/New_York&amp;rdquo;}&lt;/span&gt;&lt;/span&gt;  &lt;br /&gt;&lt;span style="color: #990000"&gt;&amp;gt;&amp;gt;&lt;/span&gt; event&lt;span style="color: #990000"&gt;.&lt;/span&gt;start_datetime&lt;br /&gt;&lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt; Wed Nov &lt;span style="color: #993399"&gt;21&lt;/span&gt; &lt;span style="color: #993399"&gt;09&lt;/span&gt;&lt;span style="color: #990000"&gt;:&lt;/span&gt;&lt;span style="color: #993399"&gt;15&lt;/span&gt;&lt;span style="color: #990000"&gt;:&lt;/span&gt;&lt;span style="color: #993399"&gt;00&lt;/span&gt; UTC &lt;span style="color: #993399"&gt;2007&lt;/span&gt;  &lt;span style="color: #990000"&gt;&lt;br /&gt;&amp;gt;&amp;gt;&lt;/span&gt; event&lt;span style="color: #990000"&gt;.&lt;/span&gt;display_start_datetime  &lt;span style="color: #990000"&gt;&lt;br /&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;&amp;ldquo;Nov. 21, 2007 09:15 AM&amp;rdquo;&lt;/span&gt;  &lt;span style="color: #990000"&gt;&lt;br /&gt;&amp;gt;&amp;gt;&lt;/span&gt; event&lt;span style="color: #990000"&gt;.&lt;/span&gt;utc_start_datetime&lt;br /&gt;&lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt; Wed Nov &lt;span style="color: #993399"&gt;21&lt;/span&gt; &lt;span style="color: #993399"&gt;14&lt;/span&gt;&lt;span style="color: #990000"&gt;:&lt;/span&gt;&lt;span style="color: #993399"&gt;15&lt;/span&gt;&lt;span style="color: #990000"&gt;:&lt;/span&gt;&lt;span style="color: #993399"&gt;00&lt;/span&gt; UTC &lt;span style="color: #993399"&gt;2007&lt;/span&gt;&lt;/pre&gt; &lt;p&gt;You can also set the value of the field to a local date/time and it will be converted to UTC automatically:&lt;/p&gt; &lt;pre style="border: 1px solid #eeeeee"&gt;&lt;span style="color: #990000"&gt;&amp;gt;&amp;gt;&lt;/span&gt; event&lt;span style="color: #990000"&gt;.&lt;/span&gt;start_datetime &lt;span style="color: #990000"&gt;=&lt;/span&gt; Time&lt;span style="color: #990000"&gt;.&lt;/span&gt;now&lt;br /&gt;&lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt; Sun Nov &lt;span style="color: #993399"&gt;25&lt;/span&gt; &lt;span style="color: #993399"&gt;06&lt;/span&gt;&lt;span style="color: #990000"&gt;:&lt;/span&gt;&lt;span style="color: #993399"&gt;26&lt;/span&gt;&lt;span style="color: #990000"&gt;:&lt;/span&gt;&lt;span style="color: #993399"&gt;35&lt;/span&gt; &lt;span style="color: #990000"&gt;+&lt;/span&gt;&lt;span style="color: #993399"&gt;0000&lt;/span&gt; &lt;span style="color: #993399"&gt;2007&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="font-style: italic"&gt;&lt;span style="color: #9a1900"&gt;#&amp;lt;Biz::Event:0&amp;times;1b71b40 @attributes={&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #ff0000"&gt;&amp;ldquo;end_datetime&amp;rdquo;&lt;/span&gt;    &lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt;  &lt;span style="color: #ff0000"&gt;&amp;ldquo;2007-11-21 15:00:00&amp;Prime;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #ff0000"&gt;&amp;ldquo;start_datetime&amp;rdquo;&lt;/span&gt;  &lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt;  Sun Nov &lt;span style="color: #993399"&gt;25&lt;/span&gt; &lt;span style="color: #993399"&gt;11&lt;/span&gt;&lt;span style="color: #990000"&gt;:&lt;/span&gt;&lt;span style="color: #993399"&gt;26&lt;/span&gt;&lt;span style="color: #990000"&gt;:&lt;/span&gt;&lt;span style="color: #993399"&gt;35&lt;/span&gt; &lt;span style="color: #990000"&gt;+&lt;/span&gt;&lt;span style="color: #993399"&gt;0000&lt;/span&gt; &lt;span style="color: #993399"&gt;2007&lt;/span&gt;&lt;span style="color: #990000"&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #ff0000"&gt;&amp;ldquo;timezone&amp;rdquo;&lt;/span&gt;        &lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt;  &lt;span style="color: #ff0000"&gt;&amp;ldquo;America/New_York&amp;rdquo;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;}&lt;/span&gt; &lt;/pre&gt; &lt;p&gt;If you want to access the fields and retrieve the database value you can use the utc_field_name method to access the UTC value of the attribute. The plugin makes a couple of core assumptions. One it assumes that the default rails timezone is UTC:&lt;/p&gt; &lt;pre style="border: 1px solid #eeeeee"&gt;ENV&lt;span style="color: #990000"&gt;[&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;TZ&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;]&lt;/span&gt; &lt;span style="color: #990000"&gt;=&lt;/span&gt; &lt;span style="color: #ff0000"&gt;&amp;lsquo;UTC&amp;rsquo;&lt;/span&gt;&lt;/pre&gt; &lt;p&gt;Second it assumes that the model has a timezone attribute named timezone:&lt;/p&gt; &lt;pre style="border: 1px solid #eeeeee"&gt;t&lt;span style="color: #990000"&gt;.&lt;/span&gt;column &lt;span style="color: #990000"&gt;:&lt;/span&gt;timezone&lt;span style="color: #990000"&gt;,&lt;/span&gt; &lt;span style="color: #990000"&gt;:&lt;/span&gt;string&lt;span style="color: #990000"&gt;,&lt;/span&gt; &lt;span style="color: #990000"&gt;:&lt;/span&gt;default &lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;&amp;rdquo;&lt;/span&gt;&lt;/pre&gt; &lt;p&gt;The plug-in depends on &lt;a href="http://tzinfo.rubyforge.org/"&gt;TZInfo&lt;/a&gt; and has been tested under Rails 1.2.3&lt;/p&gt; &lt;p&gt;You can grab a copy of the plug-in here: &lt;a href="http://www.thrivesmart.com/open_source/timezone_fu"&gt;http://www.thrivesmart.com/open_source/timezone_fu&lt;/a&gt;.&lt;br /&gt; Or if zipped is more your style: &lt;a href="http://www.thrivesmart.com/open_source/timezone_fu.zip"&gt;http://www.thrivesmart.com/open_source/timezone_fu.zip&lt;/a&gt;&lt;/p&gt; &lt;p&gt;If you love and/ or hate the plug-in feel free to leave your comments below.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</long-description>
    <name>Timezone_fu</name>
    <position type="integer">3</position>
    <purchasing-enabled type="boolean">false</purchasing-enabled>
    <short-description>A Ruby on Rails Plugin (1.2.3) That makes it easy to deal with timezones in your models</short-description>
    <size></size>
    <thumbnail-id type="integer">5263</thumbnail-id>
    <upc></upc>
    <weight></weight>
  </biz/product>
  <biz/product>
    <brand></brand>
    <business-id type="integer">77</business-id>
    <colors></colors>
    <grouping-id type="integer"></grouping-id>
    <id type="integer">806</id>
    <long-description>&lt;p&gt;Announcement Originally posted on &lt;a href="http://hackd.wordpress.com/2007/08/28/part-two-how-to-create-an-image-selection-plugin-for-tinymce-with-ruby-on-rails/"&gt;Hack'd&lt;/a&gt;&lt;/p&gt;&lt;div class="snap_preview"&gt;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: A &lt;a href="http://www.thrivesmart.com/open_source/image_select_demo_v1.0.1.zip"&gt;sample project&lt;/a&gt; is now available&lt;/p&gt; &lt;p&gt;In the &lt;a href="http://hackd.wordpress.com/2007/08/23/how-to-create-an-image-selction-plugin-for-tinymce-with-ruby-on-rails/" title="How to Create an Image Selection Plugin for tinyMCE with Ruby on Rails"&gt;first part of our how-to&lt;/a&gt; we created a tinyMCE plugin with a dynamic image selector panel based on the advimage plugin. Now we will add functionality to upload images or select an existing image.&lt;/p&gt; &lt;p&gt;Our plugin needed to satisfy the following requirements:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Use the existing inline popup (IFRAME) adding a form for uploading an image. We did not want the user to be directed to another page or create a pop up window.&lt;/li&gt;&lt;li&gt;In javascript determine which controller to call in the form because we can not pass a variable from the parent to the image selection IFRAME.&lt;/li&gt;&lt;li&gt;The image selection IFRAME should not reload when the form is submitted. Reloading the IFRAME would trigger another fetch of uploaded images and that should be avoided.&lt;/li&gt;&lt;li&gt;After an image is successfully uploaded the source and alternative text fields should be set as if the user had clicked on an existing image and the IFRAME should then disappear using the plugins existing functionality.&lt;/li&gt;&lt;/ul&gt;  &lt;p style="text-align: center"&gt;&lt;a href="http://hackd.files.wordpress.com/2007/08/picture-1.png" title="picture-1.png"&gt;&lt;img src="http://hackd.files.wordpress.com/2007/08/picture-1.png" border="0" alt="picture-1.png" /&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;To follow along with this tutorial you will need:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;The updated advimage plugin from the end of &lt;a href="http://hackd.wordpress.com/2007/08/23/how-to-create-an-image-selction-plugin-for-tinymce-with-ruby-on-rails/"&gt;How to Create an Image Selection Plugin for tinyMCE.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;The  &lt;a href="http://sean.treadway.info/svn/plugins/responds_to_parent/"&gt;responds_to_parent&lt;/a&gt; rails plugin [1] installed, Sean Treadway has a great tutorial on &lt;a href="http://sean.treadway.info/articles/2006/05/29/iframe-remoting-made-easy"&gt;using the plugin within a rails project.&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;With what we want our updated plugin to do, let&amp;rsquo;s get started!&lt;/p&gt; &lt;ol&gt;&lt;li&gt;The original image.htm (tiny_mce/plugins/ts_advimage/image.htm) has a form tag right after the body tag, we need to relocate this form in order for our image upload to function properly: &lt;pre style="border: 1px solid #eeeeee; overflow: auto"&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;body&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #009900"&gt;id&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;advimage&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;onload&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;tinyMCEPopup.executeOnLoad(&amp;rsquo;init();&amp;rsquo;);&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;style&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;display: none&amp;rdquo;&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-weight: bold; background-color: #ffffcc"&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;form&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #009900"&gt;onsubmit&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;insertAction();return false;&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;action&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;#&amp;rdquo;&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;Relocate the form just before the tabs div:&lt;/p&gt; &lt;pre style="border: 1px solid #eeeeee; overflow: auto"&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;form&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #009900"&gt;onsubmit&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;insertAction();return false;&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;action&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;#&amp;rdquo;&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;div&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #009900"&gt;class&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;tabs&amp;rdquo;&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; &lt;/li&gt;&lt;li&gt;Add a form for the image upload image.htm. Create a new div called &amp;ldquo;image-upload&amp;rdquo; to house the form. The form needs to have multipart/form-data encoding and will call a javascript function ts_onload (which we will write shortly) on submit. The target for our form is html_editor_image_upload_frame which we will create dynamically to avoid javascript errors when the plugin removes the IFRAME containing the inline popup window. &lt;pre style="border: 1px solid #eeeeee; overflow: auto"&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;div&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #009900"&gt;id&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;image-upload&amp;rdquo;&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;fieldset&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;legend&amp;gt;&lt;/span&gt;&lt;/span&gt;Upload New Image&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/legend&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;form&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #009900"&gt;id&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #009900"&gt;&amp;lsquo;image_upload_form&amp;rsquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;enctype&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;multipart/form-data&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;method&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;post&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;onsubmit&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;ts_onload(); return true;&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;target&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;html_editor_image_upload_frame&amp;rdquo;&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;input&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #009900"&gt;class&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;input-file&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;id&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;image_uploaded_data&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;name&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;image[uploaded_data]&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;size&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;30&amp;Prime;&lt;/span&gt; &lt;span style="color: #009900"&gt;type&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;file&amp;rdquo;&lt;/span&gt; &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;div&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #009900"&gt;class&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;submit&amp;rdquo;&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;input&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #009900"&gt;class&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;input-submit&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;name&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;commit&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;type&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;submit&amp;rdquo;&lt;/span&gt; &lt;span style="color: #009900"&gt;value&lt;/span&gt;&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;Upload &amp;amp; Insert&amp;rdquo;&lt;/span&gt; &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/fieldset&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; &lt;/li&gt;&lt;li&gt;Adding the form to the panel breaks the plugin because the plugin was originally written assuming that there would only be one form. We need to change instances of document.forms[0] to document.forms[1]. We could simple do a find and replace but if we ever add a form in the future we would have to do that again. Instead let&amp;rsquo;s create a function called formElement that returns the proper form: &lt;pre style="border: 1px solid #eeeeee; overflow: auto"&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt;&lt;/span&gt; &lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;formElement&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;()&lt;/span&gt; &lt;span style="color: #ff0000"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;/span&gt; document&lt;span style="color: #990000"&gt;.&lt;/span&gt;forms&lt;span style="color: #990000"&gt;[&lt;/span&gt;&lt;span style="color: #993399"&gt;1&lt;/span&gt;&lt;span style="color: #990000"&gt;];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #ff0000"&gt;}&lt;/span&gt; &lt;/pre&gt; &lt;p&gt;Now, search for instances of document.forms[0] and replace them with calls to formElement(); (there should be sixteen). &lt;/p&gt;&lt;/li&gt;&lt;li&gt;Create javascript functions to create the IFRAME and determine the path for the form action in tiny_mce/plugins/ts_advimage/jscripts/functions.jsts_onload: Create a hidden one pixel by one pixel IFRAME with an id of html_editor_image_upload_frame and add it to the end of the image-upload div we created in step two. The function also modifies our form action with the result from ts_upload_image_path(). The code highlighted below was generated [2] by &lt;a href="http://muffinresearch.co.uk/code/javascript/DOMTool/"&gt;DOMTool v1.1&lt;/a&gt; &lt;pre style="border: 1px solid #eeeeee; overflow: auto"&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt;&lt;/span&gt; &lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;ts_onload&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;()&lt;/span&gt;&lt;span style="color: #ff0000"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="font-weight: bold; background-color: #ffffcc"&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;var&lt;/span&gt;&lt;/span&gt; iframe1&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;ts_ce&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;iframe&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;,&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;html_editor_image_upload_frame&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; iframe1&lt;span style="color: #990000"&gt;.&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;setAttribute&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;rsquo;src&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;,&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;about:blank&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; iframe1&lt;span style="color: #990000"&gt;.&lt;/span&gt;style&lt;span style="color: #990000"&gt;.&lt;/span&gt;border&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;0px none&amp;rdquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; iframe1&lt;span style="color: #990000"&gt;.&lt;/span&gt;style&lt;span style="color: #990000"&gt;.&lt;/span&gt;position&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;absolute&amp;rdquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; iframe1&lt;span style="color: #990000"&gt;.&lt;/span&gt;style&lt;span style="color: #990000"&gt;.&lt;/span&gt;width&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;1px&amp;rdquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; iframe1&lt;span style="color: #990000"&gt;.&lt;/span&gt;style&lt;span style="color: #990000"&gt;.&lt;/span&gt;height&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;1px&amp;rdquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; iframe1&lt;span style="color: #990000"&gt;.&lt;/span&gt;style&lt;span style="color: #990000"&gt;.&lt;/span&gt;visibility&lt;span style="color: #990000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;hidden&amp;rdquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; iframe1&lt;span style="color: #990000"&gt;.&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;setAttribute&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;id&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;,&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;html_editor_image_upload_frame&amp;rsquo;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; $&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;image-upload&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;).&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;appendChild&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;(&lt;/span&gt;iframe1&lt;span style="color: #990000"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; $&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;image_upload_form&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;).&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;setAttribute&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;action&amp;rdquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;,&lt;/span&gt; &lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;ts_upload_image_path&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;());&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #ff0000"&gt;}&lt;/span&gt; &lt;/pre&gt; &lt;p&gt;ts_ce: A helper for creating the iframe&lt;/p&gt; &lt;pre style="border: 1px solid #eeeeee; overflow: auto"&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt;&lt;/span&gt; &lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;ts_ce&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;(&lt;/span&gt;tag&lt;span style="color: #990000"&gt;,&lt;/span&gt;name&lt;span style="color: #990000"&gt;)&lt;/span&gt;&lt;span style="color: #ff0000"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #990000"&gt;(&lt;/span&gt;name &lt;span style="color: #990000"&gt;&amp;amp;&amp;amp;&lt;/span&gt; window&lt;span style="color: #990000"&gt;.&lt;/span&gt;ActiveXObject&lt;span style="color: #990000"&gt;)&lt;/span&gt;&lt;span style="color: #ff0000"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    element &lt;span style="color: #990000"&gt;=&lt;/span&gt; document&lt;span style="color: #990000"&gt;.&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;createElement&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;&amp;lt;&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;+&lt;/span&gt;tag&lt;span style="color: #990000"&gt;+&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo; name=&amp;rdquo;&amp;lsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;+&lt;/span&gt;name&lt;span style="color: #990000"&gt;+&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;&amp;rdquo;&amp;gt;&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: #ff0000"&gt;}&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #ff0000"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    element &lt;span style="color: #990000"&gt;=&lt;/span&gt; document&lt;span style="color: #990000"&gt;.&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;createElement&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;(&lt;/span&gt;tag&lt;span style="color: #990000"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    element&lt;span style="color: #990000"&gt;.&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;setAttribute&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;name&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;,&lt;/span&gt;name&lt;span style="color: #990000"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: #ff0000"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;/span&gt; element&lt;span style="color: #990000"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #ff0000"&gt;}&lt;/span&gt; &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;/pre&gt; &lt;p&gt;ts_upload_image_path: Determine the action for the image upload form based on the URI of the parent. Divide the path into segments delimited by a forward slash. Our path_prefix is always the token after the domain name. The result is a string used to call the controller with the action for uploading images.&lt;/p&gt; &lt;pre style="border: 1px solid #eeeeee; overflow: auto"&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt;&lt;/span&gt; &lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;ts_upload_image_path&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;()&lt;/span&gt; &lt;span style="color: #ff0000"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  path_prefix &lt;span style="color: #990000"&gt;=&lt;/span&gt; window&lt;span style="color: #990000"&gt;.&lt;/span&gt;parent&lt;span style="color: #990000"&gt;.&lt;/span&gt;location&lt;span style="color: #990000"&gt;.&lt;/span&gt;pathname&lt;span style="color: #990000"&gt;.&lt;/span&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #000000"&gt;split&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;ldquo;/&amp;rdquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;)[&lt;/span&gt;&lt;span style="color: #993399"&gt;1&lt;/span&gt;&lt;span style="color: #990000"&gt;];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  to_path &lt;span style="color: #990000"&gt;=&lt;/span&gt; &lt;span style="color: #ff0000"&gt;&amp;ldquo;/&amp;rdquo;&lt;/span&gt; &lt;span style="color: #990000"&gt;+&lt;/span&gt; path_prefix &lt;span style="color: #990000"&gt;+&lt;/span&gt; &lt;span style="color: #ff0000"&gt;&amp;ldquo;/manage_images.js&amp;rdquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;/span&gt; to_path&lt;span style="color: #990000"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #ff0000"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/pre&gt; &lt;/li&gt;&lt;li&gt; With the HTML and javascript completed, let&amp;rsquo;s revisit our manage images controller. In part one our controllers respond_to block looked like this: &lt;pre style="border: 1px solid #eeeeee; overflow: auto"&gt;    respond_to &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;do&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #990000"&gt;|&lt;/span&gt;format&lt;span style="color: #990000"&gt;|&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      format&lt;span style="color: #990000"&gt;.&lt;/span&gt;html&lt;br /&gt;&lt;br /&gt;      format&lt;span style="color: #990000"&gt;.&lt;/span&gt;js&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;We need to modify our create action so it notifies the parent IFRAME that the image was uploaded. We will use a responds_to_parent block to call the javascript ts_insert_image function we wrote in part one:&lt;/p&gt; &lt;pre style="border: 1px solid #eeeeee; overflow: auto"&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;def&lt;/span&gt;&lt;/span&gt; create&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: #009900"&gt;@image&lt;/span&gt; &lt;span style="color: #990000"&gt;=&lt;/span&gt; handle_uploaded_image params&lt;span style="color: #990000"&gt;[:&lt;/span&gt;image&lt;span style="color: #990000"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  respond_to &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;do&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #990000"&gt;|&lt;/span&gt;format&lt;span style="color: #990000"&gt;|&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #009900"&gt;@image&lt;/span&gt;&lt;span style="color: #990000"&gt;.&lt;/span&gt;save&lt;br /&gt;&lt;br /&gt;      format&lt;span style="color: #990000"&gt;.&lt;/span&gt;js &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;do&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        responds_to_parent &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;do&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;          render &lt;span style="color: #990000"&gt;:&lt;/span&gt;update &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;do&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #990000"&gt;|&lt;/span&gt;page&lt;span style="color: #990000"&gt;|&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;            page &lt;span style="color: #990000"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;&amp;ldquo;ts_insert_image(&amp;rsquo;#{@image.public_filename()}&amp;rsquo;, &amp;lsquo;#{@image.name}&amp;rsquo;);&amp;rdquo;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;          &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      format&lt;span style="color: #990000"&gt;.&lt;/span&gt;js &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;do&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        responds_to_parent &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;do&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;          render &lt;span style="color: #990000"&gt;:&lt;/span&gt;update &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;do&lt;/span&gt;&lt;/span&gt; &lt;span style="color: #990000"&gt;|&lt;/span&gt;page&lt;span style="color: #990000"&gt;|&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;            page&lt;span style="color: #990000"&gt;.&lt;/span&gt;alert&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;rsquo;sorry, error uploading image&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;          &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/span&gt; &lt;/pre&gt; &lt;/li&gt;&lt;li&gt;One final step. We need to modify the responds_to_parent plugin (vendor/plugins/responds_to_parent/lib/responds_to_parent.rb) to fix a javascript error caused when the IFRAME is removed from the DOM by the tinyMCE plugin. Change the rendor block near the end of the file from: &lt;pre style="border: 1px solid #eeeeee; overflow: auto"&gt;render &lt;span style="color: #990000"&gt;:&lt;/span&gt;text &lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt; &amp;ldquo;&lt;span style="color: #ff0000"&gt;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;script type=&amp;rsquo;text/javascript&amp;rsquo; charset=&amp;rsquo;utf-8&amp;prime;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        var loc &lt;span style="color: #990000"&gt;=&lt;/span&gt; document&lt;span style="color: #990000"&gt;.&lt;/span&gt;location&lt;span style="color: #990000"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        with&lt;span style="color: #990000"&gt;(&lt;/span&gt;window&lt;span style="color: #990000"&gt;.&lt;/span&gt;parent&lt;span style="color: #990000"&gt;)&lt;/span&gt; &lt;span style="color: #ff0000"&gt;{&lt;/span&gt; setTimeout&lt;span style="color: #990000"&gt;(&lt;/span&gt;function&lt;span style="color: #990000"&gt;()&lt;/span&gt; &lt;span style="color: #ff0000"&gt;{&lt;/span&gt; window&lt;span style="color: #990000"&gt;.&lt;/span&gt;eval&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;#{script}&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;);&lt;/span&gt; loc&lt;span style="color: #990000"&gt;.&lt;/span&gt;replace&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;about:blank&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;);&lt;/span&gt; &lt;span style="color: #ff0000"&gt;}&lt;/span&gt;&lt;span style="color: #990000"&gt;,&lt;/span&gt; &lt;span style="color: #993399"&gt;1&lt;/span&gt;&lt;span style="color: #990000"&gt;)&lt;/span&gt; &lt;span style="color: #ff0000"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span style="color: #ff0000"&gt;&amp;lt;/script&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&amp;rdquo;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;To:&lt;/p&gt; &lt;pre style="border: 1px solid #eeeeee; overflow: auto"&gt;render &lt;span style="color: #990000"&gt;:&lt;/span&gt;text &lt;span style="color: #990000"&gt;=&amp;gt;&lt;/span&gt; &amp;ldquo;&lt;span style="color: #ff0000"&gt;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;script type=&amp;rsquo;text/javascript&amp;rsquo; charset=&amp;rsquo;utf-8&amp;prime;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  var loc &lt;span style="color: #990000"&gt;=&lt;/span&gt; document&lt;span style="color: #990000"&gt;.&lt;/span&gt;location&lt;span style="color: #990000"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  with&lt;span style="color: #990000"&gt;(&lt;/span&gt;window&lt;span style="color: #990000"&gt;.&lt;/span&gt;parent&lt;span style="color: #990000"&gt;)&lt;/span&gt; &lt;span style="color: #ff0000"&gt;{&lt;/span&gt; setTimeout&lt;span style="color: #990000"&gt;(&lt;/span&gt;function&lt;span style="color: #990000"&gt;()&lt;/span&gt; &lt;span style="color: #ff0000"&gt;{&lt;/span&gt; window&lt;span style="color: #990000"&gt;.&lt;/span&gt;eval&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;#{script}&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;);&lt;/span&gt;&lt;span style="font-weight: bold; background-color: #ffffcc"&gt; try &lt;span style="color: #ff0000"&gt;{&lt;/span&gt; loc&lt;span style="color: #990000"&gt;.&lt;/span&gt;replace&lt;span style="color: #990000"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000"&gt;&amp;lsquo;about:blank&amp;rsquo;&lt;/span&gt;&lt;span style="color: #990000"&gt;);&lt;/span&gt; &lt;span style="color: #ff0000"&gt;}&lt;/span&gt; &lt;span style="font-weight: bold"&gt;&lt;span style="color: #0000ff"&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;(&lt;/span&gt;ignored&lt;span style="color: #990000"&gt;)&lt;/span&gt;&lt;span style="color: #ff0000"&gt;{}&lt;/span&gt; &lt;span style="color: #ff0000"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #990000"&gt;,&lt;/span&gt; &lt;span style="color: #993399"&gt;1&lt;/span&gt;&lt;span style="color: #990000"&gt;)&lt;/span&gt; &lt;span style="color: #ff0000"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #ff0000"&gt;&amp;lt;/script&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&amp;ldquo; &lt;/pre&gt; &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;You now have a new tinyMCE image plugin that allows a user to select an existing uploaded image or use a form to upload a new image. Once the image is uploaded the IFRAME is removed from the DOM and the image is inserted into the tinyMCE text box.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt;&lt;li&gt;The responds_to_parent plugin  allows   &amp;ldquo;AJAX&amp;rdquo; style file uploads  by posting a form to a hidden IFRAME.&lt;/li&gt;&lt;li&gt;Dynamic IFRAME  javascript code was generated by  &lt;a href="http://muffinresearch.co.uk/code/javascript/DOMTool/"&gt;http://muffinresearch.co.uk/code/javascript/DOMTool/ &lt;/a&gt;- &amp;ldquo;The compatibility mode for attributes in Internet Explorer is only required should the user need to use innerHTML or outerHTML to get hold of the markup for a form. Using either name properties or setAttribute results in the name attributes being present in the document but not available to innerHTML or outerHTML. When disabled DOMTool uses setAttribute to generate name attributes&amp;rdquo;&lt;/li&gt;&lt;/ol&gt; &lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</long-description>
    <name>Image Selection and Upload Plugin for TinyMCE</name>
    <position type="integer">30</position>
    <purchasing-enabled type="boolean">false</purchasing-enabled>
    <short-description>For TinyMCE 2 with Rails 1.2.3 and attachment_fu</short-description>
    <size></size>
    <thumbnail-id type="integer">5264</thumbnail-id>
    <upc></upc>
    <weight></weight>
  </biz/product>
</biz/products>
