Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2009-08-04 05:11:47

X*
New member
Registered: 2009-08-03
Posts: 5

EFM: support for huge directories (more than 10.000 pictures)

Using: Xinha 0.96beta2, PHP 5.2.6, and any real Web browser (I say "real" because I haven't tested with Microsoft's IE)

1. First, all my apologizes for such a poor formatting in this post, but I can only handle Xinha's text-formatting tools wink

2. We are here talking about the editor's "insert image" functionality, which is bound - in our case - to ExtendedFileManager (EFM).

3. The suggestion here intends to make the ExtendedFileManager plugin work even if it has to parse several thousands pictures.

4. It wasn't tested using "link" mode, only "image". Yet it could work (well, probably... don't you want to try?).

5. The following trick is NOT to be part of Xinha's releases, since it prevents from using some tools (e.g. the pictures' options below the list of pics). Therefore I thought a message in the forum would do, better than a ticket but I can be wrong...


If you tried to implement EFM and had nothing displayed because of a too high number (over 28.000 for me) of pictures in the images' root folder (you can have either a "maximum execution time" error, a "memory allocation" error, or even no error but no display anyway), this could be of interest for you.

When EFM parses a directory (using PHP's Directory object, see php.net/manual/en/class.dir.php), it retrieves extra data from each picture, like dimensions (ExtendedFileManager::getImageInfo), and some other stuff gathered by the stat function (see php.net/manual/en/function.stat.php). These two calls (getImageInfo and stat) make the algorithm very slow because it has to open the file. Here we can see why this solution can't be official part of Xinha: you'll have to delete these lines. It will issue no error, but dimensions' options will be disabled.

In xinha/plugins/ExtendedFileManager/Classes/ExtendedFileManager.php, look for

$img = $this->getImageInfo($fullpath.$entry);

in function getFiles($path), and replace it by

$img = null;

This will force $file['image'] to contain default dimensions, zero by zero.

Just below, find the line

$file['stat'] = stat($fullpath.$entry);

and replace it by

$file['stat'] = false;

I guess $file['stat'] could be valued to null or zero, but the stat function may return false, so let's comply with the standard smile

Finally, in order to make it work, and work fast, add in your configuration the value

$IMConfig['view_type'] = 'listview';

in order to have directly a faster display and avoid errors with memory (I guess thumbnails take a lot of it)

One more thing: never forget to thank Xinha's community for such a nice wysiwyg, because if it hadn't been written like it is we couldn't make fixes like this one so easily wink

Have fun!

Offline

Board footer

Powered by FluxBB