Generating thumbnails

B

Barely Audible

Guys

I was wondering if it was possible to have a js file that, when the page
loaded, it automatically generated a a set of thumbnails from directory
of the page on the web server?

Or would this create an unacceptable security hazard?

TTFN
Barely
 
L

-Lost

Barely said:

What about the gals, huh? You chauvinistic pig. ;)
I was wondering if it was possible to have a js file that, when the page
loaded, it automatically generated a a set of thumbnails from directory
of the page on the web server?

Well, sure you can. However, there is a problem. I'll tell you at the
end of my post.

var imgs = ['my_mom', 'my_child', 'some other picture', 'pron'];

for (var i = 0, l = imgs.length; i < l) i++)
{
var new_img = document.createElement('img');
new_img.src = imgs + '.jpg'; // or you could store the extension
document.getElementsByTagName('body')[0].appendChild(new_img);
}

Or you could just loop the array and write the results to the page using
the write method or innerHTML.
Or would this create an unacceptable security hazard?

The problem is by not creating thumbnails server-side or at least with
an image resizing application, you are creating unnecessary loading
times. Not to mention the fact that you end up loading too much
information in the user's browser or other viewing device.

Think on this. If I have ten images that are each 10 megabytes, then
the user has to load 100 megabytes of information just to view
thumbnails that you resize via CSS or JavaScript.

Serve them resampled thumbnails and you eliminate this problem.
 
B

Barely Audible

oink oink Guilty as charged ;-)

You have a valid point... as regards file size fortunately they do not
get that size and double figures KB is more the norm. The problem is
that the contents of the directory changes 10-15 times a day! I would be
forever redoing thumbnails if I had to do it manually :-(

You know of an example of this type of script in action?

-Lost said:
Barely said:

What about the gals, huh? You chauvinistic pig. ;)
I was wondering if it was possible to have a js file that, when the page
loaded, it automatically generated a a set of thumbnails from directory
of the page on the web server?

Well, sure you can. However, there is a problem. I'll tell you at the
end of my post.

var imgs = ['my_mom', 'my_child', 'some other picture', 'pron'];

for (var i = 0, l = imgs.length; i < l) i++)
{
var new_img = document.createElement('img');
new_img.src = imgs + '.jpg'; // or you could store the extension
document.getElementsByTagName('body')[0].appendChild(new_img);
}

Or you could just loop the array and write the results to the page using
the write method or innerHTML.
Or would this create an unacceptable security hazard?

The problem is by not creating thumbnails server-side or at least with
an image resizing application, you are creating unnecessary loading
times. Not to mention the fact that you end up loading too much
information in the user's browser or other viewing device.

Think on this. If I have ten images that are each 10 megabytes, then
the user has to load 100 megabytes of information just to view
thumbnails that you resize via CSS or JavaScript.

Serve them resampled thumbnails and you eliminate this problem.
 
R

Rene Tschaggelar

Barely said:
oink oink Guilty as charged ;-)

You have a valid point... as regards file size fortunately they do not
get that size and double figures KB is more the norm. The problem is
that the contents of the directory changes 10-15 times a day! I would be
forever redoing thumbnails if I had to do it manually :-(

You know of an example of this type of script in action?

Do it on the server once. And not on the client.

Rene
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top