0

当用户要向文章中添加图像时,我使用图像列表使他能够在单独的部分中添加图像并将它们添加到来自 tinyMCE 的文章中,但是如果我们有大量图像,用户会发现长名单!这一点都不容易吗?所以我希望找到一种方法让每篇文章都有自己的图片列表images_list.php?article_id=333..

手风琴是一个部分中所有文章标题的容器,当单击编辑或使用 tinymce 添加 ajax 时,如何更改每篇文章的 external_image_list_url 属性??????

4

1 回答 1

0

当使用 php 文件生成 javascript 列表时,例如来自 moxiecode 的这个示例,您应该能够根据文章获取图像。

玩得开心 !

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