Decreasing Page Load

Permalink Browser Info Environment
I am using the sortable fancybox to display an image gallery.

The Block is added from the dashboard to a page when the user creates a gallery album.

I am finding that with large amounts of images that the initial page load is quite substantial.

I am aware this may very well be a mix of things mainly the javascript being in the header(conccrete5 issue). But think the getThumbnail() could be adding to the overheads. Especially if the gallery page has not cached the thumbnail images?

Do you think it is possible to move the thumbnail processing out of the view? and also have it within the edit/add to essentially preload the cache with the images?

I'm not sure if I am asking the right question here? and I am aware this not related to Sortable-Fancybox but I wander if you have any thoughts on this and if I could move it away from the view?

Type: Discussion
Status: New
TheRealSean
View Replies:
jordanlev replied on at Permalink Reply
jordanlev
Hi,
The thumbnail caching happens on the server, which means that only the very first time the page is visited by anyone (e.g. you in edit mode) is when it needs to create the thumbnail images. After that initial view, the thumbnails are loaded the same as any other image -- straight from the filesystem without any processing.
If thumbnail processing was moved out of the view, it wouldn't really make much of a difference -- you're either waiting for that first load of the page or you're waiting for the "thumbnail generation" process to complete. Maybe it just needs better explanation to the user about what's happening?

The full-size images that appear in the zoomed-out lightbox are only loaded when a thumbnail is clicked, so those don't have any effect on the original page load either.

I don't think the javascript files would add that much additional time to the page load (and those are cached by the browser so only the first visit to a page on your site should require them to be fetched anyway).

I'm definitely not trying to say that you're wrong and that it's fast enough -- just wanted to narrow down the options. How many images are you talking about?

Thanks.

-Jordan
TheRealSean replied on at Permalink Reply
TheRealSean
around 100+ images.

The pages are fine once the images have been generated, its just that I have integrated the creation of the album into the dashboard. Meaning the client can add galleries from the dasboard and have the page created.

I was not sure about the javascript being in the head, testing the c5 on steroids I am noticing an improvement with it being in the footer but not by much.

I suppose I was hoping that I could add the process within the edit/add functions to prevent the user from having to do this thumbnail processing on view. Or if the user was to click the page the images are processed after the page has loaded not on the initial link to the page being clicked.

Its not too much of an issue I can ask the client to load the page after creating the album.

Im going to attempt(attempt being the key word here) to create a "File Set" page attribute at some point so hopefully this could then be achieved without the dashboard.

Thank you for your help, this is outside of what your gallery is intended to do so I appreciate the help.

- Sean


--edit--
I re read your post, and if I am understanding you correctly I can create a function that runs from either the edit/add then I wont need the view function to process the thumbnails.

My client is aware of the processing time its the end user that I would like to prevent from having to wait too long.

Ill get back to my notepad and play some more.
jordanlev replied on at Permalink Reply
jordanlev
Okay I understand your situation now.

What I would do is add some code to your dashboard page that gets triggered after adding/editing a page with the gallery on it -- this code should load the gallery block and call its view() function, which shouldn't actually output anything but will cause all of the thumbnailing functions to take place (so that the first time the page is loaded, the thumbnail generation has already happened and it will load from the cache instead). You'll probably want some kind of "loading..." or "processing..." indicator so the user knows it's doing something.

I am pretty sure this code will do the trick:
$bID = 5; //<-- you will have to provide this somewhow
$b = Block::GetById($bID);
$bi = $b->getInstance();
$bi->view();


If you only have the page's collection id and need to get the gallery block ID for it, you can call "BlockType::getByHandle('sortable_fancybox_gallery')->getBlockTypeID();" to get the btID, then query the database (query CollectionVersions to get the latest/approved cvID for the page, then query CollectionVersionBlocks to get the blockID for the given cvID and btID). Note that you might get more than one bID in response if there's more than one gallery on the page, so make sure you loop through the results and call the code up above for each one.

I also have some code that will loop through all of the blocks on a given page so you could inspect them for the proper blockTypeHandle and call the view() method on each one directly -- let me know if you want that (but I think the above method of querying the database is a bit cleaner).

Hope that helps!

-Jordan

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.