サポート » プラグイン » Ktai Entryにてlightbox→my-hacks.php設置で文字化け

  • 解決済 cwic

    (@cwic)


    質問失礼します。

    Ktai Entryにてlightboxを使用する為、
    http://wppluginsj.sourceforge.jp/ktai_entry/qa/#lightbox

    の方法にてmy-hacks.phpという書類名で上記指定のコードをコピペしてindex.phpと同階層に設置、管理画面での設定も行なってブラウザを更新したところ、管理画面全体とブログが文字化けしレイアウトが崩れてしまいました。

    上記のエラーを解決しつつ、rel=”lightbox”を反映させる方法が分かる方がいらっしゃったら是非教えてください。

    よろしくお願いします。

    ちなみにmy-hacks.phpの内容は以下になります。

    function ke_rel_lightbox($html, $id, $size) {
    if (preg_match(‘/rel=[“\’]/’, $html, $match)) {
    $html = str_replace($match[0], $match[0] . ‘lightbox ‘, $html);
    } elseif (! preg_match(‘/rel=/’, $html)) {
    $html = str_replace(‘<a ‘, ‘<a rel=”lightbox” ‘, $html);
    }
    return $html;
    }
    add_filter(‘image_link/ktai_entry.php’, ‘ke_rel_lightbox’, 10, 3);

4件の返信を表示中 - 1 - 4件目 (全4件中)
  • モデレーター IKEDA Yuriko

    (@lilyfan)

    プラグイン作者です。

    my-hacks.php の文字コードはどうされていますでしょうか。
    UTF-8 にした場合、BOM なし (もしくは UTF-8N) で保存しないといけません。Windows 附属の「メモ帳」の場合、UTF-8 の BOM ありでしか保存できないため、問題が発生します。コードには日本語が入っていないので、Shift_JIS ないし US-ASCII にして保存すれば大丈夫のはずです。

    たぶん文字コードを直せば動くと思いますが、それでもダメならば、PHP, MySQL, Apache のバージョン、および、サーバーの php.ini もしくは phpinfo() を確認して mbstring の設定がどうなっているか教えてください。

    トピック投稿者 cwic

    (@cwic)

    返信ありがとうございます。

    まず、自分の作業環境ですが、MAC OS 10.4.11 にて
    「mi2.1(MACOSX)」というテキストエディットを使用しています。

    Shift_JISに変更してみましたが上手くいきませんでした。

    サーバーはCPIサーバーの共用サーバー
    MySQLバージョン>5.0.45
    PHPバージョン>5.2.4

    サーバーの機能一覧ページ

    PHP.iniのmbstringの設定は以下になります。

    [mbstring]
    ; language for internal character representation.
    mbstring.language = Japanese

    ; internal/script encoding.
    ; Some encoding cannot work as internal encoding.
    ; (e.g. SJIS, BIG5, ISO-2022-*)
    mbstring.internal_encoding = EUC-JP

    ; http input encoding.
    mbstring.http_input = auto

    ; http output encoding. mb_output_handler must be
    ; registered as output buffer to function
    mbstring.http_output = SJIS

    ; enable automatic encoding translation according to
    ; mbstring.internal_encoding setting. Input chars are
    ; converted to internal encoding by setting this to On.
    ; Note: Do _not_ use automatic encoding translation for
    ; portable libs/applications.
    mbstring.encoding_translation = Off

    ; automatic encoding detection order.
    ; auto means
    mbstring.detect_order = auto

    ; substitute_character used when character cannot be converted
    ; one from another
    mbstring.substitute_character = none;

    ; overload(replace) single byte functions by mbstring functions.
    ; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(),
    ; etc. Possible values are 0,1,2,4 or combination of them.
    ; For example, 7 for overload everything.
    ; 0: No overload
    ; 1: Overload mail() function
    ; 2: Overload str*() functions
    ; 4: Overload ereg*() functions
    ;mbstring.func_overload = 0

    モデレーター IKEDA Yuriko

    (@lilyfan)

    mbstring.internal_encoding = EUC-JP
    mbstring.http_output = SJIS

    これらはあきらかにまずいのですが、1行目についてはこの設定に影響される関数がないので大丈夫ですし、2行目については

    mbstring.encoding_translation = Off

    となっているので影響はないように思えます。念のため、mbstring.http_output は pass にしてみてください (php.ini もしくは .htaccess で変更)。

    トピック投稿者 cwic

    (@cwic)

    lilyfanさんありがとうございます。
    他の記事でもありましたが、自分も<?php ?>で囲むのを忘れていました………

    <?php ?>で囲んでShift_JISで保存し直したところ上手くいきました!ありがとうございます。

4件の返信を表示中 - 1 - 4件目 (全4件中)
  • トピック「Ktai Entryにてlightbox→my-hacks.php設置で文字化け」には新たに返信することはできません。