title: Adding modal to upload image in a custom component in joomla 2.5
body: <p>I am trying to built my custom component, in which I want to upload image from administrator.
  For uploading image I want to use media manager modal, and that should return the image url in my text box. I have made following changes in the popup-imagemanager.js:</p>
  
  <pre><code>this.editor = decodeURIComponent(q.get('e_name')); //after this
  //I added
  this.return_url = decodeURIComponent(q.get('return_url'));
  </code></pre>
  
  <p>and</p>
  
  <pre><code>//window.parent.jInsertEditorText(tag, this.editor);
  
  //removed above line and added the following
  
  if ( this.return_url == 1 ) 
  { 
   window.parent.document.getElementById(this.editor).value=url; 
  } 
  else 
  { 
   window.parent.jInsertEditorText(tag, this.editor); 
  } 
  </code></pre>
  
  <p>and the code in my form is as under:</p>
  
  <pre><code>&lt;input class="text_area" type="text" name="imageurl" id="imageurl" size="50" maxlength="250" value="&lt;?php echo $this-&gt;image-&gt;image;?&gt;" /&gt; 
  
   &lt;div class="button2-left"&gt; 
    &lt;div class="image"&gt; 
     &lt;a rel="{handler: 'iframe', size: {x: 570, y: 400}}" href="index.php?      option=com_media&amp;view=images&amp;tmpl=component&amp;e_name=imageurl&amp;return_url=1"
     title="Image" class="modal-button"&gt;Select&lt;/a&gt; 
    &lt;/div&gt; 
  &lt;/div&gt; 
  </code></pre>
  
  <p>When I click the insert button after selecting an image in the modal, I get the error:<br>
        window.parent.document.getElementById(this.editor) is null</p>
  
  <p>I searched for it but was unable to solve it. Pls tell me what to do . Thnx </p>