By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,359 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

Is its possible to preload dynamic images?

P: n/a
I use database to store images. So img-tags are like
<img src="viewer.php?img_id=100">

Can I use javascript/php-combination to preload images of whole site after
first page is loaded? Or does all the images get loaded again automatically
if they have dynamic urls? If so, can that behaviour be changed?
This is the typical jscript i guess:
//-------------------------
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-------------------------
So then I should write something like this(supposing that I have already
done in php a mysql_query that gets all th necessary images:
<body onload=" MM_preloadImages(<? $str="";
while($row=mysql_fetch_assoc($result)) {$str.=
"\"viewer.php?image_id=".$row['image_id']."\"," } $str =substr($str, 0,
strlen($str)-1); echo $str; ?>);"
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
What about testing is with a huge image?

Just try if dynamic URL's for images are cached on a few systems.

Regards,
Erwin Moller
Jul 17 '05 #2

P: n/a

"Erwin Moller"
<si******************************************@spam yourself.com> kirjoitti
viestissä news:40d94049$0
What about testing is with a huge image?
Just try if dynamic URL's for images are cached on a few systems.


It seems to be that no they aren't. But images are either sent with php's
image_jpg etc or more manually by sending headers first and rawa data then.
Maybe headers are the problem since I use image_jpg and it doesn't give a
chance to manipulate headers. But I dont' have very much experience with
headers. What headers should I send if I send them manually.
Jul 17 '05 #3

P: n/a
"Perttu Pulkkinen" <pe**************@co.jyu.fi> schrieb im Newsbeitrag
news:tg**************@read3.inet.fi...

"Erwin Moller"
<si******************************************@spam yourself.com> kirjoitti
viestissä news:40d94049$0
What about testing is with a huge image?
Just try if dynamic URL's for images are cached on a few systems.
It seems to be that no they aren't. But images are either sent with php's
image_jpg etc or more manually by sending headers first and rawa data

then. Maybe headers are the problem since I use image_jpg and it doesn't give a
chance to manipulate headers. But I dont' have very much experience with
headers. What headers should I send if I send them manually.

I am not sure about that. But what you could do anyway is write the image to
a file and link that file. So the Dreamweaver preload function has a normal
jpg file to preload. Maybe you will need to write a cleanup script to delete
outdated image files from your server later.

HTH
Markus
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.