Web Hosting Talk







View Full Version : Creating seperate index files for each image (or something similar)


svtVIB
01-11-2008, 04:19 AM
I created a website and I have an index.html; and in there, I have it linking to a rotate.php file which randomly generates a new image from a directory every time you refresh the page. However, if you right click and try to find the image properties, it shows the rotate.php file instead of the image URL. You can see what I am talking about at <<URL removed>> but be warned, the image it pops out at you may not be work safe!!

What I would really like to do, is make it so that others can send the link of the image to whomever they wish... but I was thinking what I would really like is for each image to have its own page. So if someone sent <<URL removed>>"/random/free_cat_sign.jpg" to a friend, they would see something like the front page (with whatever text/html/etc I want on it) instead of just the image itself.

It's kind of hard for me to explain, so if you have any questions that I can answer that may help you understand better, please feel free to ask.

Thank you.

Xeentech
01-11-2008, 05:00 AM
Well what I'd do is, insted of having a static HTML link to rotate.php for the image, I'd have index.php make HTML that links to a particular IMG.. and under the image you can make a perminant link to the img..

svtVIB
01-11-2008, 03:44 PM
Wouldn't this require a separate html file for each image? I have over 700 images on there now and I plan to put on many more.

svtVIB
01-11-2008, 03:55 PM
Maybe if I could have the link of every image in the folder sort of redirect to 1 HTML file that would have the image in it. Is there a way to do that? Maybe with the .htacces file?

nnormal
01-11-2008, 04:35 PM
<? $imageDir="images/"; ?>
<script>
function dsp(i) {
var e=document.getElementById('dspimg');
e.src=i;
e.style.display="block"
}
</script>
<table>
<tr>
<td valign="top">
<? foreach (glob($imageDir."*.jpg") as $i) //or .gif or whatever..
echo ' <li><a href="javascript:dsp(\''.$i.'\')">'.$i.'</a>'; ?>
</td>
<td valign="top">
<img id="dspimg" style="display:none;">
</td>
</tr>
</table>



if you wanted to set the image from the url you could use HTML DOM Location Object
http://www.w3schools.com/htmldom/dom_obj_location.asp