Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum
https://www.tinywebgallery.com/forum/

Is there a way to cache "random images"?
https://www.tinywebgallery.com/forum/viewtopic.php?f=1&t=315
Page 1 of 1

Author:  Fabricio [ 17. May 2006, 06:47 ]
Post subject:  Is there a way to cache "random images"?

I've used the code available on How-To 4 (How to setup a random image on a different site/frame) to make the thumbnails in this page:

Although it works fine, it takes too long (and too much processor cycles) to build all the thumbnails on the fly. Is there any way to cache these images?

Thanks

Author:  TinyWebGallery [ 17. May 2006, 09:44 ]
Post subject: 

Hi,

I cannot connect to you server through our firewall :(.

But yes I have some code to reuse the thumbs if the random pic size = the thumbsize!

you have to open image.php and scroll to the very bottom. There are some comments

/*
$thumb = "./" . $cachedir . "/" . urlencode(str_replace("/", "_", $twg_album) . "_" . $image) . "." . $extension_thumb;
if (file_exists($thumb) && ($randomimagesize == $thumb_pic_size)) {
putimage($thumb);
} else {
*/

and

// }

further down - remove the /* */ and the //

Then the thumb is used if the sizes match. I commented this because you can make watermarks on the thumbs too - but I don't use this - therefore using this few lines is fine.
It does only work for "easy" filenames - I haven't encoded everything properly there! I'll do this for the next release.

/Michael

Author:  TinyWebGallery [ 17. May 2006, 09:51 ]
Post subject: 

ok - I fixed that on my local build.

If you have uncomented the lines you have in this part 2 times $image

change this to

urldecode($image)

then it wis working for all filenames

/Michael

Author:  fbreve [ 17. May 2006, 19:18 ]
Post subject: 

Hi,

That would not work for me because the random images and the thumbs are different in sizes.

I'd like to cache the random images themselves.

Maybe this URL works under firewall (thought the images are in the other saves and may not load due to the firewall restrictions):

Author:  TinyWebGallery [ 18. May 2006, 01:49 ]
Post subject: 

Then you have to change the generateRandom function of inc/imagefunctions.inc.php

Right now the images are not saved - you wouild just have to save them and if they are already present use them.

I have used this a couple of times in TWG already - If shouldn't be a big deal to do this for random images too.

/Michael

Author:  TinyWebGallery [ 23. May 2006, 09:05 ]
Post subject: 

Hi I added this to the latest build of TWG (uploaded 23.5. - still 1.4.2).

see $enable_random_image_caching in the config.php ;).
it's disabled by default.

/Michael

Author:  fbreve [ 23. May 2006, 09:20 ]
Post subject: 

Hi Michael,

Thanks a lot :)

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/