Is its possible to preload dynamic images?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Perttu Pulkkinen

    Is its possible to preload dynamic images?

    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_preloadImage s() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.leng th,a=MM_preload Images.argument s; 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_preloadImage s(<? $str="";
    while($row=mysq l_fetch_assoc($ result)) {$str.=
    "\"viewer.php?i mage_id=".$row['image_id']."\"," } $str =substr($str, 0,
    strlen($str)-1); echo $str; ?>);"


  • Erwin Moller

    #2
    Re: Is its possible to preload dynamic images?

    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

    Comment

    • Perttu Pulkkinen

      #3
      Re: Is its possible to preload dynamic images?


      "Erwin Moller"
      <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> kirjoitti
      viestissä news:40d94049$0[color=blue]
      > What about testing is with a huge image?
      > Just try if dynamic URL's for images are cached on a few systems.[/color]

      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.


      Comment

      • Markus Ernst

        #4
        Re: Is its possible to preload dynamic images?

        "Perttu Pulkkinen" <perttu.pulkkin en@co.jyu.fi> schrieb im Newsbeitrag
        news:tgcCc.104$ fl5.57@read3.in et.fi...[color=blue]
        >
        > "Erwin Moller"
        > <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> kirjoitti
        > viestissä news:40d94049$0[color=green]
        > > What about testing is with a huge image?
        > > Just try if dynamic URL's for images are cached on a few systems.[/color]
        >
        > 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[/color]
        then.[color=blue]
        > 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.
        >[/color]
        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


        Comment

        Working...