Currently the IMCE editor display all files without paging. Оn sites with lot of images/files rendering may take long time.
This patch add a cosmetic pager (still all files info fetched) and give ability to decide how many images/files to show.

Also the prev/next links are only shown if needed (so on the first page there is no prev, and if the file-count is already < files/page there is no need for next)


ufku’s picture

Status: Active » Closed (won't fix)
fizk’s picture

@ufku, why won't this feature be added? I'm currently working on a site that needs paging due to the large number of image files.

sillygwailo’s picture

Version: 6.x-2.0-rc2 » 6.x-2.x-dev
Status: Closed (won't fix) » Needs review
10.38 KB

Patch re-rolled for 2.x with some whitespace cleanup. This was needed for a site with quite a large number of files as well, so I'm re-opening this.

er.pradeep’s picture

Issue summary: View changes

Hi All,

I have worked on patch #974568 for making working it on Drupal 7 with IMCE with version = "7.x-1.9" for adding pagination on pop up window of IMCE for file listing. Now this patch is working. Please try this.

ladybug_3777’s picture

I am VERY interested in your patch er.pradeep! I will check out your patch, however, why did not you attach the patch directly to this issue? (just curious)

ladybug_3777’s picture

This patch is not written using typical Drupal standards. It should not be written to include your personal file system path "sites/all/modules/contrib/IMCE" instead it should be applied from within IMCE directly. You cannot guarantee that all users will have the same directory structure for their modules, some use /sites/default, some use sites/all/modules (no contrib) etc.

Can you please re-roll the patch with this change so others can also try it easily. Please see this post for tips on patch file creation. :-)

I'll see if I can get your patch to apply to my dev environment and I'll provide some additional feedback for you.

ladybug_3777’s picture

Version: 6.x-2.x-dev » 7.x-1.9
13.39 KB

Here is the same patch, re-rolled with the directory paths changed so it will apply properly. I've just started testing it and it has some potential for sure. There's a few small quirks I am noticing (For example the number of files that it lists is a little buggy), but this gives me a good place to start. If I add/fix/change functionality I'll be sure to come back with an updated patch.

Thanks to those who put in some work on this functionality!

ladybug_3777’s picture

Version: 7.x-1.9 » 7.x-1.x-dev
12.12 KB

Another quick re-roll of the patch so it will cleanly apply on the latest dev version too. (last patch was written for version 1.9).

Patch has not been modified other than the version is applies against.

This applied, but I think I am missing a file somehow. Will be back with an update

ladybug_3777’s picture

Missing file re-added. Please do NOT use the patch in comment #8, instead use this one on #9 (I don't know how to delete/hide files from old comments, otherwise I would!)

ladybug_3777’s picture

Hmmmm... I'm noticing more quirks with this patch, so it will need some work for sure. The URL it is using to perform the paging is causing problems. (I'm losing my "Select" button once I start using the pager) Again, I appreciate the first attempt from er.pradeep! It just needs a little work and maybe we can get this working better.

ladybug_3777’s picture

ladybug_3777’s picture

Making progress! I believe I've fixed the issue with the links. I'm now loading in the proper URL variables so the select button is functioning properly now.

There are a few small quirks to still be worked out and I'll be trying to fix them as I have time. There are some issues I see that are related to having low numbers in the Maximum number of pages to display (for example, anything lower than 4). I'm also occasionally seeing an extra blank page in the pager as well.

I have a lot more tests to run, but at least this patch is now useable. As I make progress I will continue to update this issue.

I will hide the other patches I've written and make sure only the most current is displayed in the top of this post. (I finally figured out how to do that!)

If anyone else would like to take a look and help contribute please feel free!!

ladybug_3777’s picture

ladybug_3777’s picture

ugh, more issues. Looks like my idea of using the $_GET parameter to fix the link issues is flawed. When changing directories the $_GET array contains ajax information such as:


Grrrrrr... back to the drawing board.

ladybug_3777’s picture

Status: Needs review » Needs work

I'm working out a new solution. Will post again when I make progress

ladybug_3777’s picture

Status: Needs work » Needs review
14.32 KB

Here is a new patch that addresses the issues I was seeing. I handled the pager URL issue with a session variable and I'm not sure if there would be a better way to access the information I need, but this does work. I also fixed the extra blank page issue, the low number "maximum number of pages to display" problem, and the issue with numbering once you get to the end of the paging. (I know this may sound vague if you haven't tried previous patches, but I want it documented for anyone that may).

This is far from perfect, and still needs more testing, but I believe it's good enough to encourage others to give it a try and provide feedback.

As always if I improve upon it I'll be back with a new update.

FYI, This patch will apply fine to dev and version 1.9 of IMCE

ladybug_3777’s picture

ladybug_3777’s picture

Status: Needs review » Needs work

After doing some more testing I realized that sorting by column headers is not working as expected. Although sorting is being performed on click of a header, it's only sorting the current page results, not results across all pages.

Another issue I'm running into is on one of my apache servers when the number of files is extremely large (which is why I need the pager in the first place!) I'm seeing the value of "Transfer-Encoding:Chunked" on any ajax calls. This is causing overall default sorting to break down too because it appears to be unable to sort on all records since the response is being "chunked"

I'm trying to understand how IMCE is performing all of it's sorting tasks (I believe it's all being done within js/imce_extras.js) and seeing if there is any way to tweak it a bit for the way this pager works.

Moving the status back to "Needs Work"

ladybug_3777’s picture

Little progress has been made with this since I realized the issue with sorting. This patch prevents the HTML file rows from being printed out into the HTML so there's no way to sort of rows that aren't output.

I've played around a bit with adding back the removed HTML file rows and then adding functions to .hide() and .show() based on the sorts selected, but the idea really isn't coming together. Not to mention that this pager is coded to reload the browser window with each click of a new page in the pager.

I'm now looking to start over and see what I can do with a custom module to add on the pager functionality, rather than try to change the way IMCE works.

Any help or advice appreciated!!

ladybug_3777’s picture

Creating a custom module to handle the large amount of files in each directory is going OK. I've decided to create a year filter and a cosmetic pager. If anyone is interested in the functionality please feel free to check out the repository here:

Hopefully it will help you out or at least get you started on a path that will prevent IMCE from totally locking up.

I'm open to new ideas and suggestions so feel free to chime in!

ladybug_3777’s picture

Back to provide an update:

The custom module i created with paging and the year filter isn't working out as well as I had hoped. If you use IMCE Tools for searching you'll notice search breaks down once I search, and find something that isn't displayed with my year filter turned on (meaning I find a file from 2013, but my filter is restricting the list to 2016).

I'm also seeing small issues when uploading new files or when creating new copies of files via cropping, thumbnails, resizing.

I ended up abandoning the custom year/pager module for now, there are just too many hurdles to overcome.

For now, I've added a year token to the directory structure for my image fields. I'm hoping this will help reduce overall folder size and will then speed up display. It's not the optimal solution, but it has helped us squeak by for now.

SerkanB’s picture

I took the patch from #16 and worked on it.

I'm not that happy with the implementation... but it works.

Since I had the issue with S3 and I can't really count the number of files without iterating thorugh them, I removed the "total pages" calculation.

It's a pager that works... that's all what counts for me right now. You're free to make it better :D

SerkanB’s picture

Issue summary: View changes
12.2 KB

Well, had an issue with directories... fixed that. (They were also skipped... when I only wanted files to be skipped.)

Now they disappear when one is an directory, also the paging isn't perfect with directories. But it works for me (better as the current situation... which results in a 5xx-Error after loading for 5mins).

SerkanB’s picture

12.51 KB

Just realized, forgot to add the pager-tpl ...