Announcement

  •  » Engine
  •  » [multisize] AJAX load for thumbnails

#1 2012-01-30 22:43:30

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

[multisize] AJAX load for thumbnails

Last time we've talked about the way thumbnails are loaded, we said let's see how Piwigo behaves when it has to load 30 thumbnails not in the cache.

Now I see and honestly, I think we should use a solution equivalent to [extension by P@t] GThumb+, ie based on AJAX, 3 thumbnails at once.

With Gthumb+ :

1) thumbnails are loaded gracefully
2) thumbnails are loaded in the right order
3) the server suffers less

Offline

 

#2 2012-01-31 13:22:59

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [multisize] AJAX load for thumbnails

But this is only "one time" the first time we go on the page, than everything will be there. Do we really need a complicated stuff only for this ? Or it's enough to let users know that the first time we look at a thumbnail, it will be slower ?
PS: Zenphoto/Gallery3 do not do anything special I believe

Offline

 

#3 2012-02-05 00:14:40

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

Re: [multisize] AJAX load for thumbnails

OK, I've also discussed with P@t on this subject and yes it's "a bit" complicated to have this by default.

But I keep saying that the loading of a page with 30 thumbnails not in the cache (and my photos are 10 megapixel big) is awfully slow and highly increases the load of my computer. What I'll implement is :

1) at upload time, pre-cache thumbnail
2) at upload time, pre-cache the default size

Of course, if the derivative algorithm could generate the thumbnail from the default size instead of the original, it would be much faster and less CPU/memory consuming.

Offline

 

#4 2012-02-05 02:11:34

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

Re: [multisize] AJAX load for thumbnails

[Subversion] r13030 pre-cache the thumbnail, please tell me if I did it the best way (ie a fetchRemote on i.php).

Offline

 

#5 2012-02-05 10:41:56

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [multisize] AJAX load for thumbnails

plg wrote:

[Subversion] r13030 pre-cache the thumbnail, please tell me if I did it the best way (ie a fetchRemote on i.php).

it looks good (just don't get the reason of preg_replace)

Offline

 

#6 2012-02-05 10:42:25

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [multisize] AJAX load for thumbnails

plg wrote:

Of course, if the derivative algorithm could generate the thumbnail from the default size instead of the original, it would be much faster and less CPU/memory consuming.

I'll implement that in i.php ...

Offline

 

#7 2012-02-05 10:56:53

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

Re: [multisize] AJAX load for thumbnails

rvelices wrote:

plg wrote:

[Subversion] r13030 pre-cache the thumbnail, please tell me if I did it the best way (ie a fetchRemote on i.php).

it looks good (just don't get the reason of preg_replace)

the pre_replace is useful when the add_uploaded_file function is called from admin/include/uploadify/uploadify.php, but maybe I should have implemented it another way, so that the called script is a the root of Piwigo: it leads to several preg_replace like this and it's a bit ugly I admit.

I've tested with upload from pLoader, iPhoto, Flash Uploader, Browser Uploader.

Offline

 

#8 2012-02-06 11:39:55

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [multisize] AJAX load for thumbnails

plg wrote:

the pre_replace is useful when the add_uploaded_file function is called from admin/include/uploadify/uploadify.php, but maybe I should have implemented it another way, so that the called script is a the root of Piwigo: it leads to several preg_replace like this and it's a bit ugly I admit.

This is very strange. It means we have a bug because set_make_full_url() is supposed to be working and remove all admin/include ...

Offline

 

#9 2012-02-06 22:35:45

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

Re: [multisize] AJAX load for thumbnails

rvelices wrote:

plg wrote:

Of course, if the derivative algorithm could generate the thumbnail from the default size instead of the original, it would be much faster and less CPU/memory consuming.

I'll implement that in i.php ...

I think this is what you did in [Subversion] r13038. So maybe I should change my algorithme to

1) pre-cache the default size
2) pre-cache the thumbnail

How do I know the default size?

rvelices wrote:

plg wrote:

the pre_replace is useful when the add_uploaded_file function is called from admin/include/uploadify/uploadify.php, but maybe I should have implemented it another way, so that the called script is a the root of Piwigo: it leads to several preg_replace like this and it's a bit ugly I admit.

This is very strange. It means we have a bug because set_make_full_url() is supposed to be working and remove all admin/include ...

Well... in Piwigo the file loaded by the web server is always at the root of Piwigo (index.php, picture.php, admin.php...), correct me if I'm wrong. So I think the case was not expected in set_make_full_url().

In your opinion, should I try to fix set_make_full_url() and/or change the way uploadify.php is loaded. Now that I see all specific changes done for this exception, which was first coded as a plugin, I think I should move the load of uploadify.php to something like upload_backend.php at the root of Piwigo.

Offline

 

#10 2012-02-07 07:04:53

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [multisize] AJAX load for thumbnails

plg wrote:

Well... in Piwigo the file loaded by the web server is always at the root of Piwigo (index.php, picture.php, admin.php...), correct me if I'm wrong. So I think the case was not expected in set_make_full_url().

It was (all code is in function cookie_path() ). If it does not work, it is a bug. But I'm pretty sure it should work (I'm using in gmaps mapl.php in plugins dir and cookie path work properly)

Offline

 

#11 2012-02-07 11:08:08

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [multisize] AJAX load for thumbnails

plg wrote:

1) pre-cache the default size
2) pre-cache the thumbnail

How do I know the default size?

ImageStdParams::get_defined_type_map contains all the enabled derivative parameters sorted ascending by size (use array_reverse).
You should split it in two groups: those with watermark and those without
Then you can build the two groups in parrallel.

While I'm thinking, another idea would be at the end of i.php, after saving the requested derivative, find a smaller one to generate from the current one. For example you request size medium, you generate it and then you could crop and save the result as the square ... But let's be careful - in my opinion if you generate medium->small->thumb->square, the squares would be over-sharpened because of multiple Lanczos filter ...

Offline

 

#12 2012-02-29 22:33:33

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

Re: [multisize] AJAX load for thumbnails

Now that we have a bit more experience with cache generation for thumbnails, including generating several thumbnails at once on "low" servers like 1&1, we've seen that very often, it was necessary to refresh the page 3 or 4 times to get all the thumbnails. That is just not "fine".

We've discussed about this problem with rvelices last monday and even if he doesn't like the concept of adding Ajax just because of the first load might fail, he agrees that it is a problem (rvelices, tell me if I didn't understand correctly your point of view). As we (mainly P@t) have the experience with Gthumb+ of loading thumbnails with Ajax.

P@t has reproduced the Ajax load on the default theme. I made some tests and it is a "much better" user experience:

1) thumbnails are loading in the expected order
2) all thumbnails are loaded, no need to refresh several times (must be tested on many "slow" servers)
3) smaller load on the server (the user don't care but the web server will appreciate)

[Subversion] r13444

Offline

 

#13 2012-03-01 09:18:20

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [multisize] AJAX load for thumbnails

@plg, it was exactly my point of view.

The commit looks good with 3 comments:
- in derivative.inc.php if the conf url_style is already 1 or 2, then is_cached will always be false. In this case I would initialize it to true
- rv_tscroller will not work properly if thumbs are not already cached
- currently there are two calls to i.php (one with ajaxload and one setting .src=url). it requires some heavier js code but it could be reduced to one call

Offline

 

#14 2012-03-01 17:33:11

P@t
Piwigo Team
Nice
2007-06-13
4098

Re: [multisize] AJAX load for thumbnails

rvelices wrote:

- in derivative.inc.php if the conf url_style is already 1 or 2, then is_cached will always be false. In this case I would initialize it to true

Fixed: [Subversion] r13452

rvelices wrote:

- rv_tscroller will not work properly if thumbs are not already cached

Fixed: [Subversion] r13453

rvelices wrote:

- currently there are two calls to i.php (one with ajaxload and one setting .src=url). it requires some heavier js code but it could be reduced to one call

No, there is only one call to i.php.... when src attribute of images is set after ajax loading, the url is the cached one, not i.php.


P@t

Offline

 

#15 2012-03-26 07:12:04

ddtddt
Piwigo Team
Quetigny - France
2007-07-27
7201

Re: [multisize] AJAX load for thumbnails

lalashafer wrote:

What is rv_tscroller?

[extension by rvelices] RV Thumb Scroller


You love Piwigo so don't hesitate to participate, learn more on the "Contribute to Piwigo" page. If you don't have much time for contribution, you can also help the project with a donation.

Offline

 
  •  » Engine
  •  » [multisize] AJAX load for thumbnails

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact