サポート » プラグイン » Comment Image デザイン変更

  • Comment Imageのfile formデザインを変更しようと下記のようにしたのですが上手くいかず困っています。

    plugin.php(119行目)
    echo '<p style="clear: both"><input style="width: auto" type="file" name="image' . ($i==0?'':$i) . '"/> ' . htmlspecialchars($options['label']) . '</p>';
    上記を下記に変更

    
    echo '<div class="form-group" style="width:250px";"><div class="input-group">';
                  echo '<input type="file" id="file_input" name="file_input" style="display: none;">';
                  echo '<span class="input-group-btn"><button class="btn btn-default" type="button" onclick="$("{#file_input}").click();">';
                  echo '<i class="glyphicon glyphicon-folder-open"></i></button></span>';
                  echo '<div class="input-group"><input id="dummy_file" type="text" class="form-control" placeholder="select file..." disabled></div></div></div>';
    

    comments.php内の<?php comment_form(); ?>下あたりに下記を追加

    <script type="text/javascript">
      jQuery(function($){
        $('#file_input').change(function() {
          $('#dummy_file').val($(this).val());
        });
      })
    </script>

    希望通り表示はできているのですがクリックしても反応しません。
    どのように修正すれば良いのかアドバイスをお願い致します。

3件の返信を表示中 - 1 - 3件目 (全3件中)
  • プラグインを直接編集した場合アップデートで上書きしたら機能しなくなるので止めた方が良いです。
    以下をテーマのfunctions.phpに追記してみてください。

    if ( function_exists( 'commentimage_comment_form' ) ) {
    remove_action( 'comment_form', 'commentimage_comment_form', 99 );
    function my_commentimage_comment_form() {
    ?>
    <script type="text/javascript">
      jQuery(function($){
        $('#file_input').change(function() {
          $('#dummy_file').val($(this).val());
        });
      })
    </script>
    <div class="form-group" style="width:250px"><div class="input-group">
    <input type="file" id="file_input" name="image" style="display: none;">
    <span class="input-group-btn"><button class="btn btn-default" type="button" onclick="jQuery('#file_input').click();">
    <i class="glyphicon glyphicon-folder-open"></i></button></span>
    <div class="input-group"><input id="dummy_file" type="text" class="form-control" placeholder="select file..." disabled></div></div></div>
    <?php
    }
    add_action( 'comment_form', 'my_commentimage_comment_form' );
    }
    トピック投稿者 NANOPASS

    (@nanopass)

    ありがとうございます。

    上手くいったんでしょうか?
    解決したなら解決済にしてください。

3件の返信を表示中 - 1 - 3件目 (全3件中)
  • トピック「Comment Image デザイン変更」には新たに返信することはできません。