Is there any way to make a picture automatically link to itself?
I have a website with a gallery set of pictures I'm working on. The client wants the pictures to be enlarged when users click on them. They are ok with them just opening a link to the picture on a white page that is the path of the picture. I.E http://web.com/folder/picture.jpg.
There are a lot of pictures is there anyway using html, css, or php to to make the pictures开发者_开发百科 automatically link to themselves?
Or
Would it be better to figure out how to make the pictures enlarge themselves after you place the mouse over them for a second or two?
About the animation for opening the images, you should look at javascript plugins, the term you are looking for is lightbox.
About the 'autoloading' of images, you should take a look at PHP. The fastest why to do that is by loading all the images in a gallery into a separate directory in two sizes (for example /images/thumbs/image_1.jpg and /images/full/image_1.jpg) - use batch resize and save them consistently. That what you do with the PHP is, that you read the directory with this:
$imgs_per_div = 4;
$i = 1;
$images_in_dir = glob("images/thumbs/*.jpg");
foreach ($images_in_dir as $thumb_image)
{
$filename = basename($thumb_image);
$large_image = 'images/full/' . $filename;
if ($i == 1 || $i % $imgs_per_div == 0)
echo '<div>';
echo "<a href='$large_image'><img src='$thumb_image'/></a>";
if ($i % $imgs_per_div + 1 == 0 || $i == count($images_in_dir))
echo '</div>';
$i++;
}
I haven't tested the code but it should work for you by setting the correct path to images. This should draw out all images in the preset directory.
it sounds like your hand coding the html/images? you should be using php to loop through all the images and build the html that way
edit: you should look into using the jquery plugin called fancybox for displaying the full size images, its simple and looks professional
Consider using a lightbox. They are quite easy to code, and help to create a great user experience. There are also many ready made scripts that you can use by just modifying a couple lines of your code.
http://www.lokeshdhakar.com/projects/lightbox2/
精彩评论