1

管理者から画像をアップロードしたいカスタムコンポーネントを作成しようとしています。画像をアップロードするために、メディアマネージャーモーダルを使用したいのですが、テキストボックスに画像のURLが返されるはずです。私はpopup-imagemanager.jsに以下の変更を加えました:

this.editor = decodeURIComponent(q.get('e_name')); //after this
//I added
this.return_url = decodeURIComponent(q.get('return_url'));

//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); 
} 

私のフォームのコードは次のとおりです。

<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> 

モーダルで画像を選択した後に挿入ボタンをクリックすると、エラーが発生します:
window.parent.document.getElementById(this.editor)はnullです

私はそれを探しましたが、それを解決することができませんでした。plsは私に何をすべきか教えてくれます。Thnx

4

2 に答える 2

1

私があなたの質問を正しく理解しているなら、あなたは画像を閲覧するためにあなたのカスタムコンポーネントにメディアマネージャーを使いたいと思っています、そして画像の1つを選択するとそれはあなたの入力フィールドに表示されます。したがって、次の方法でそれを行うことができます。

コンポーネントでを開き、画像を保存するメディアmodels->forms-> open the .xml fileとしてフィールドタイプを追加します。

Test.xml

<field id="image"
  name="enter field name"
  type="media"
  label="Select Image"
  description=""
  class="inputbox"
  directory="Enter the image path here" 
/>

これでお役に立てば幸いです。

于 2013-03-05T08:50:16.967 に答える
0

タグのクラスは「モーダル」である必要があります。

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>
于 2017-11-13T19:39:54.850 に答える