Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image tinyMCE
#27
IMAGE LIST FEATURE ON TINYMCE

Hi Internet54, thanks for your reply

I have found a way to implement the IMAGE LIST feature, when you click on INSERT IMAGE of TinyMCE. **and** refreshing that lisk automatically.

1- Mofigy ADMIN/edit.php in order to add the IMAGE LIST (changes on bold)
// Theme options xxx
theme_advanced_buttons1 : "formatselect,styleselect,bold,italic,underline,justifyleft,justifycenter,justifyright,bullist,numlist,link,unlink,image,cleanup,removeformat",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
relative_urls:false,
external_image_list_url : "tinymce_image_list.php"
});

2- Fill list contens and make it dinamically update:
Create the file ADMIN/tinymce_image_list.php
with this content (i am also attaching the file to make it easy)

Code:
<?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 = "../data/uploads"; // 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);
}

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

header('Content-type: text/javascript'); // Make output a real JavaScript file!

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

?>

This function will explore your DATA/UPLOADS/ folder, and create a list with its files.
You can change the code to only check for JPG PNG GIF files, and it will be nice helping clients on not link an IMG SRC to a PDF file...

thanks to TinyMCE WIKI on http://wiki.moxiecode.com/index.php/Tiny...e_list_url to show me the way Smile

should be this on scripts ?
Reply


Messages In This Thread
Image tinyMCE - by haplo37 - 2009-08-12, 00:44:11
Image tinyMCE - by gameover - 2009-08-12, 01:47:05
Image tinyMCE - by Xashen - 2009-08-12, 05:32:46
Image tinyMCE - by n00dles101 - 2009-08-12, 05:43:27
Image tinyMCE - by Xashen - 2009-08-12, 06:04:56
Image tinyMCE - by n00dles101 - 2009-08-12, 06:11:55
Image tinyMCE - by gameover - 2009-08-12, 07:32:46
Image tinyMCE - by ccagle8 - 2009-08-12, 07:56:18
Image tinyMCE - by gameover - 2009-08-12, 08:16:24
Image tinyMCE - by n00dles101 - 2009-08-12, 18:59:18
Image tinyMCE - by ccagle8 - 2009-08-13, 11:57:34
Image tinyMCE - by alexd0001 - 2009-08-31, 23:54:17
Image tinyMCE - by kotos - 2009-09-02, 01:10:03
Image tinyMCE - by bnowell - 2009-09-02, 05:32:15
Image tinyMCE - by ccagle8 - 2009-09-02, 08:24:21
Image tinyMCE - by ccagle8 - 2009-09-03, 20:31:21
Image tinyMCE - by Sanddorn - 2009-10-05, 22:14:30
Image tinyMCE - by badcat - 2009-10-07, 08:22:52
Image tinyMCE - by focoves - 2009-12-12, 06:29:28
Image tinyMCE - by focoves - 2009-12-12, 06:31:42
Image tinyMCE - by Zegnåt - 2009-12-12, 21:33:09
Image tinyMCE - by focoves - 2009-12-12, 22:29:45
Image tinyMCE - by Zegnåt - 2009-12-13, 00:19:07
Image tinyMCE - by internet54 - 2009-12-17, 08:49:45
Image tinyMCE - by internet54 - 2009-12-17, 17:09:02
Image tinyMCE - by Zegnåt - 2009-12-17, 18:01:32
Image tinyMCE - by focoves - 2009-12-19, 01:57:46
Image tinyMCE - by internet54 - 2009-12-19, 02:19:24
Image tinyMCE - by focoves - 2009-12-19, 03:17:04
Image tinyMCE - by internet54 - 2009-12-19, 06:45:41
Image tinyMCE - by Zegnåt - 2009-12-20, 02:28:01
Image tinyMCE - by focoves - 2009-12-20, 03:11:42
Image tinyMCE - by Zegnåt - 2009-12-20, 22:05:52



Users browsing this thread: 1 Guest(s)