3
Contributors
4
Replies
18
Views
2 Years
Discussion Span
Last Post by cereal
0

Try this,

<a href="page.html"><img src="img_to_the_path" alt="image_description"/></a>

Edited by Lau_1

0

@cereal. thanks for your answer but this is not what im looking for.
I want that my photo (for example) open in another .html page (designed) with another structure.
@lau 1. thanks for ur answer, this is not what im looking for.

0

Hmm, I'm not sure I've understood your request.

Let's try: you have to define the image in the destination page, which can be done with a static or a dinamic approach.

When using a static method just create the page that will show a pre-defined image:

page.photo01.html

And point the browser to that specific page.

When using a dynamic method you create a container, a page that can elaborate and display the contents accordingly with the sent input.

The input can be sent by using GET and POST methods, which are HTTP verbs to access web resources. Below I'm going to show you a simple GET request approach:

You have to set a query string to the opening link so you can send the file name, for example:

<a href="page.php?img=photo01.jpg">
    <img src="/images/photo01.jpg">
</a>

Note page.php?img=photo01.jpg in the href attribute, you have to use a PHP file (or another server side scripting language), because you need to access the query string parameters.

So, in the page.php file you write something like this:

<?php

    $img   = array_key_exists('img', $_GET) ? basename($_GET['img']) : FALSE;

    # web path, used to display the file in the browser
    $path  = '/images/';
    $image = $path . $img;
?>
<!DOCTYPE>
<html>
...

<!-- display image here -->
<?php
    # display the image
    if($img) echo "<img src=\"{$image}\">";

    # default image (not required)
    else echo "<img src=\"/images/default.jpg\">";
?>

If you don't want to use server side languages, you can go with Javascript and read the query string from there. It's up to you.

If this still does not answer to your question, please add an extended example and information.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.