I checked the option "Replace the existing file with the new one" in "Common settings" of IMCE configuration. But when I upload a new picture with an already existing name in the file browser, the picture that is shown in the preview wrapper is the old one, and not the file that I 'd just uploaded.
To see the new image, I need to reload the page with F5 keybord key.

How this images refresh in the file browser can be applied automatically when a new file is uploaded ?

Thanks

Comments

lucuhb’s picture

Category: bug » support
ufku’s picture

Status: Active » Fixed

One way is to override imce.imgHtml() method

imgHtml: function (fid, width, height) {
  return '<img src="'+ imce.getURL(fid) +'?'+ Math.random() +'" width="'+ width +'" height="'+ height +'" alt="'+ imce.decode(fid) +'">';
}

This will disable browser cache for images in preview.

lucuhb’s picture

Status: Fixed » Active

Thanks you very much.

Actually, with these changes in imce.js, image in preview is automatically refresh , but only in the preview part : the primary image is still displayed in the files list part.
Is there any way to solve this problem ?

It would be nice if your changes in the code of imcs.js are incorporated to the imce release.

ufku’s picture

Should the file disappear from the list??
BTW, you can override any imce method in imce-content.tpl.php file. Copy it to your theme's directory and see how inline javascript is added in it to extend imce.

lucuhb’s picture

Of course I don't want the file disappear from the liste, I just want that the little preview in file list is also refresh.

After all, your solution refreshs the image in preview part, but when I return to the fckeditor window, the image shown in this is the initial one and not the new one.
With F5 key of the keybord, images are updated for the imce window and for the fckeditor too.

So I'm not sure that there is a way to replace refreshment by F5 key.

However thanks you for your help.

ufku’s picture

Ok, it's clear now. That little thumbnail is created by imce.thumbRow() in imce_extras.js
You can override the line: img.src = imce.getURL(row.id) + '?' + Math.random()

I can't commit these changes to the project because they disable the browser cache and force a server request whenever an image is previewed. It would be painful when you view a directory containing hundreds of images each shown as a thumbnail in the list.

ufku’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.