Reputation: 924
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:
this.editor = decodeURIComponent(q.get('e_name')); //after this
//I added
this.return_url = decodeURIComponent(q.get('return_url'));
and
//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);
}
and the code in my form is as under:
<input class="text_area" type="text" name="imageurl" id="imageurl" size="50" maxlength="250" value="<?php echo $this->image->image;?>" />
<div class="button2-left">
<div class="image">
<a rel="{handler: 'iframe', size: {x: 570, y: 400}}" href="index.php? option=com_media&view=images&tmpl=component&e_name=imageurl&return_url=1"
title="Image" class="modal-button">Select</a>
</div>
</div>
When I click the insert button after selecting an image in the modal, I get the error:
window.parent.document.getElementById(this.editor) is null
I searched for it but was unable to solve it. Pls tell me what to do . Thnx
Upvotes: 1
Views: 2172
Reputation: 1
The class in a tag must be "modal".
JHTML::_('behavior.modal');
<a rel="{handler: 'iframe', size: {x: 570, y: 400}}" href="index.php?option=com_media&view=images&tmpl=component&e_name=imageurl&return_url=1"
title="Image" class="modal">Select</a>
Upvotes: 0
Reputation: 4711
If i understand your question right you want to use media manager into your custom component for browse images and when select one of image then it's show to your input field. So you can do it by the following method:
In your component open the models->forms-> open the .xml file
and add the field type as media where you want to save the image.
For example : Test.xml
<field id="image"
name="enter field name"
type="media"
label="Select Image"
description=""
class="inputbox"
directory="Enter the image path here"
/>
that's it.Hope this will help.
Upvotes: 1