Author Topic: [SOLVED] Error while uploading and a fix  (Read 7267 times)

0 Members and 1 Guest are viewing this topic.

Offline jabberwock

[SOLVED] Error while uploading and a fix
« on: 28. May 2008, 20:53:32 »
[SOLVED - See Solution]
A user pointed out to me that while creating or editing an entry, in the gallery plugin iframe, if you add and delete the same image over and over ('browse for a file, upload, then delete by clicking the 'x' beside the image' over and over again) the thumbnail which is displayed in the box stays the same sometimes. After a bit of investigation it turns out the browser is caching the thumbnail, so when a new thumbnail is uploaded the browser shows the cached thumbnail even though the image has changed on the server.

This is easily solved by forcing the browser to get the new thumbnail file. We can do this by changing the name of the file that the system tries to show.

change the following: gallery.class.php  ~line 493
$imageName "{$folderId}_image_{$filePos}.{$fileExt}";
$thumbName "{$folderId}_thumb_{$filePos}.{$fileExt}";


if(
sobi2Config::translatePath("{$savePath}|{$imageName}"nulltruenull)) {
	
$tempArray = array ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','r','s','t','u','t','t','t' );
	
$tempStr $tempArray[rand(0,20)].$tempArray[rand(0,20)].$tempArray[rand(0,20)];
	
$imageName "{$folderId}_image_{$filePos}_{$tempStr}.{$fileExt}";
	
$thumbName "{$folderId}_thumb_{$filePos}_{$tempStr}.{$fileExt}";
}


change it to


$tempArray 
= array ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','r','s','t','u','t','t','t' );
$tempStr $tempArray[rand(0,20)].$tempArray[rand(0,20)].$tempArray[rand(0,20)];
$imageName "{$folderId}_image_{$filePos}_{$tempStr}.{$fileExt}";
$thumbName "{$folderId}_thumb_{$filePos}_{$tempStr}.{$fileExt}";

if(
sobi2Config::translatePath("{$savePath}|{$imageName}"nulltruenull)) {
	
$tempStr $tempArray[rand(0,20)].$tempArray[rand(0,20)].$tempArray[rand(0,20)];
	
$imageName "{$folderId}_image_{$filePos}_{$tempStr}.{$fileExt}";
	
$thumbName "{$folderId}_thumb_{$filePos}_{$tempStr}.{$fileExt}";
}



this forces the name of the file to change each time it's uploaded, making sure the browser updates the thumbnail file.

Michael
« Last Edit: 18. December 2011, 01:38:34 by aboututila »
We are what we repeatedly do. Excellence, then, is not an act, but a habit - Aristotle
Country: Canada Canada |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile Dynamic Code Works

Offline tifra

Re: Error while uploading and a fix
« Reply #1 on: 16. December 2008, 00:47:41 »
Bravo!! I had the same problem, applied this fix and it's working for 100%.

Many thanks.
Tifra
Country: Netherlands Netherlands |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline aboututila

Re: Error while uploading and a fix
« Reply #2 on: 16. December 2011, 23:23:58 »
Problem fixed in Gallery Plugin v2.5.5 and later.

Regards - Mark
« Last Edit: 18. December 2011, 01:39:42 by aboututila »
Country: Honduras Honduras |  OS: Windows XP Windows XP |  Browser: Firefox 8.0 Firefox 8.0 | View Profile

Tags: