0

ユーザーが記事に画像を追加しようとしているときに、画像リストを使用して別のセクションに画像を追加し、tinyMCE から記事に追加できるようにしましたが、大量の画像がある場合はどうなるでしょうか。長いリスト!! それはまったく簡単ではないでしょうか?だから私は、各記事に独自の画像リストimages_list.php?article_id=333..を持たせる方法を見つけたいと思っています。

アコーディオンは、[編集] をクリックするか、tinymce で ajax を追加すると、セクション内のすべての記事のタイトルのコンテナーですが、各記事の external_image_list_url プロパティを変更する方法?????

4

1 に答える 1

0

このmoxiecodeの例のように、phpファイルを使用してjavascriptリストを生成すると、記事に応じて画像を取得できるはずです。

楽しむ !

PHP で生成されたイメージ リスト ファイルの例

<?php // this must be the very first line in your PHP file!

// You can't simply echo everything right away because we need to set some headers first!
$output = ''; // Here we buffer the JavaScript code we want to send to the browser.
$delimiter = "n"; // for eye candy... code gets new lines

$output .= 'var tinyMCEImageList = new Array(';

$directory = "../../img"; // Use your correct (relative!) path here

// Since TinyMCE3.x you need absolute image paths in the list...
$abspath = preg_replace('~^/?(.*)/[^/]+$~', '/$1', $_SERVER['SCRIPT_NAME']);

if (is_dir($directory)) {
    $direc = opendir($directory);

    while ($file = readdir($direc)) {
        if (!preg_match('~^.~', $file)) { // no hidden files / directories here...
             if (is_file("$directory/$file") && getimagesize("$directory/$file") != FALSE) {
                // We got ourselves a file! Make an array entry:
                $output .= $delimiter
                    . '["'
                    . utf8_encode($file)
                    . '", "'
                    . utf8_encode("$abspath/$directory/$file")
                    . '"],';
            }
        }
    }

    $output = substr($output, 0, -1); // remove last comma from array item list (breaks some browsers)
    $output .= $delimiter;

    closedir($direc);
}

// Finish code: end of array definition. Now we have the JavaScript code ready!
$output .= ');';

// Make output a real JavaScript file!
header('Content-type: text/javascript'); // browser will now recognize the file as a valid JS file

// prevent browser from caching
header('pragma: no-cache');
header('expires: 0'); // i.e. contents have already expired

// Now we can send data to the browser because all headers have been set!
echo $output;

?>
于 2011-03-13T12:40:16.147 に答える