CKEditor Free Image Browse Plugin

Place for comments, problems, questions, or any issue related to the JavaScript / PHP scripts from this site.
Admin
Site Admin
Posts: 805

CKEditor Free Image Browse Plugin

Here add issues about the CKEditor with Image Browser and Uploder Plugins from this page: CKEditor Free Image Browse Plugin.

kwinans Posts: 1
Thank you for posting the Image Browser plugin for CKeditor. It is helpful to see how you did this. However, the server-side script imgbrowse.php caused me some trouble initially. You used the "short array" syntax (introduced in PHP 5.4) in 2 places. I am still using PHP 5.3.x (for legacy reasons with some code on one of my sites). On lines 7 and 18 of imgbrowse.php, the syntax you use for array declaration is not compatible with PHP versions less than 5.4.x.

So, if you are using PHP 5.3 or earlier, line 7 should be changed to:

Code: Select all

protected $imgext = array('bmp', 'gif', 'jpg', 'jpe', 'jpeg', 'png'); // PHP < 5.4.x syntax
And line 18 should be changed to:

Code: Select all

$re = array('menu'=>'', 'imgs'=>'');
BTW, because this caused a fatal error, there was never any return from the server and it just looked like nothing happened once the browse window opened. It was frustrating to find.

Again, thanks for posting this solution for CKeditor. Once I made these changes, everything worked fine.
Ken

Admin Posts: 805
Hi,
Thank you for posting the problem and the solving on forum. It is helpful for those who use PHP version 5.3 or earlier.
I added these changes on site, in the page of this plugin.

- In addition, $fileobj->getExtension() (on line 35) is only available as of PHP 5.3.6, for earlier version it can be used: pathinfo($fileobj->getFilename(), PATHINFO_EXTENSION) instead.
So, for those who use PHP older than 5.3.6, change the line 35 to:

Code: Select all

if($fileobj->isFile() && in_array(pathinfo($fileobj->getFilename(), PATHINFO_EXTENSION), $this->imgext)) $re['imgs'] .= '<span><img src="'. $site . $this->root . $this->imgdr . $name .'" alt="'. $name .'" height="50" />'. $name .'</span>';