Вопрос

I'm trying to create a simple image gallery that displays thumbnails of uploaded images. Once a thumbnail is clicked, I would like to be directed to a page with the large version of the image, along with a comment section. So basically I'm trying to do something similar to deviantart. What I have now looks something like this:

<a href="<?php echo $image->large_image_path; ?>"> <img src="<?php echo $image->thumbnail_image_path; ?>"></a>

Clicking on a thumbnail will take to me to the large image path, which is not really what I want. Any help is greatly appreciated.

Это было полезно?

Решение

You must make the href="<?php echo $image->large_image_path; ?>" to somehing like href="show_image.php?image_path=<?php echo $image->large_image_path; ?>"

In show_image.php you can den get the path of the image by $_REQUEST['image_path'], and add it into the code like this:

<img src="<?php echo $_REQUEST['image_path']; ?> />

The you can add information or styling around the bigger image.

So, link to a PHP page instead of the image. Even better, put the image path in to a database, and use the image id to get the path and information of the image. Like this:

href="show_image.php?image_id=<?php echo $image->id; ?>"> and then in show_image.php, given that you have a method for getting the image:

<?php $image = GetImage($_REQUEST['image_id']); ?>
<img src="<?php echo $image->large_image_path; ?> />
<?php echo $image->description; ?> 
<?php echo $image->date; ?>

Hope this helps you on the way.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top