Page 2 of 2

Re: Create Static Page from JPEG

Posted: Fri Jul 31, 2009 9:33 am
by Nytol
I couldn't get what you showed me to work, but I have made some progress with your help with view.php.

My main_image div code looks like this now...

Code: Select all

<?php $p = $posts[0]; ?><a href="http://www.domain.com/view.php?n=<?php echo $p['image']; ?>"><img src="" /></a>
When I click a .jpg, in the main_image div, a new page opens (now with a header and footer...yay) and it works great. But, it loads the same image into the new page whatever image I click in the main_image div. I guess it's loading the first image in the array which I don't want.

The bit that is really confusing me is what to put after view.php?n= in my main_image div so that the corresponding image loads into the new page. I can't seem to get the a href information of the main image into view.php.

I was wondering if there was a way to scan the main_image div for the a href of the image, and put that information into some sort of PHP code? So then I would have view.php?n=<?php code ?>?

Edit: In fact, forget the <?php $p = $posts[0]; ?> that is for something else I need to run. I just have that so the first thumbnail of the first image shows when you initially load the page.

Re: Create Static Page from JPEG

Posted: Fri Jul 31, 2009 10:08 am
by jackpf
I'm not sure I understand...

What's $p['image']?

Re: Create Static Page from JPEG

Posted: Fri Jul 31, 2009 10:41 am
by pickle
I think there's a simple solution here, but I want to make sure I know what you're trying to accomplish. This is what I've managed to piece together:

You've got a main page that has a bunch of thumbnails on it. When the user clicks a thumbnail, the image is loaded into the main_image div. When the user clicks that bigger photo in the main_image div, they are taken to the view.php?n=blah blah page that shows the image at full size.

Am I correct?

Re: Create Static Page from JPEG

Posted: Fri Jul 31, 2009 11:21 am
by Nytol
Yep. Exactly.

thumbnail div - Bunch of thumbnails

main_mage div - A big image which appears after you click a thumbnail.

Both divs on index.php in the root of the webserver.

I got the code from a really cool banner rotator (http://www.sohtanaka.com/web-design/exa ... e-rotator/)

Now after the thumbnail has been clicked, and the full size image appears in the main_image div, I want visitors to be able to click the full size image again and be taken to a new page (view.php?n=blahblah) where the image will have it's own unique page. :)

I did a little research and maybe I could use preg_match to grab the first IMG SRC in the main_image div, and place that at the end of view.php?

Re: Create Static Page from JPEG

Posted: Fri Jul 31, 2009 11:25 am
by Nytol
jackpf wrote:I'm not sure I understand...

What's $p['image']?
$p['image'] is the images stored in my database. I call these images into thumbnail div. It gets a little bit crazy because I also added an image resizer (image.php).

This is the code in my thumbnail div...

Code: Select all

<a href="http://www.domain.com/common/image.php<?php echo $p['image']; ?>/?width=659&height=1200&image=<?php echo $p['image']; ?>"><img src="<?php echo $p['thumb']; ?>"/></a>
So it takes the images already in my database, creates a new resized image for main_image div.

Re: Create Static Page from JPEG

Posted: Fri Jul 31, 2009 11:44 am
by pickle
If the thumbnail stuff is working, then you obviously know in Javascript the filename you want to link to. Just give the <a> tag in your main_image div an ID, then in jQuery you can do this:

Code: Select all

var imagename = 'name_of_image.jpg';
$("#idoflink").attr('href','view.php?n='+imagename);

Re: Create Static Page from JPEG

Posted: Fri Jul 31, 2009 3:58 pm
by jackpf
Oh right. Didn't know that :oops: