Page 3 of 3

Re: photo gallery

Posted: Tue Jan 22, 2013 9:43 pm
by Robbedoesie
I am still trying to get the main image on the same page as the thumbnails and still I am not succeeding. I am still trying because I think it must be possible.

I have a few questions.
Where you use $image on line 38 above it will not have an array value since you define it as false near the top. I'm not really sure what should be in it's place :/ maybe it should be based on $_GET['image_id'] ? You could keep the value form the loop too, you would just need to use a different variable name.
After the $image = false; I can't use the variable $image anymore, it then maybe should be based on $_GET['image_id']. Can you give my an example of how I could do that because I don't know what you mean. Or I could keep the value of the loop but then with a different variable name. I tried for example $image = $img to get a different variable name with the value from the loop but maybe it is not a good way to change a variable name?

The code is now;
<?php 
include 'core/init.php';

if (isset($_GET['album_id'])) {
	$album_id = $_GET['album_id'];
$album_data = album_data($album_id, 'name', 'description');

echo '<h3>', $album_data['name'], '</h3><p>', $album_data['description'], '</p>';

$albums = get_albums();
$images = get_images($album_id);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<div id="wrap">
<div id="sidebarleft">
<?php

if (empty($images)) {
        echo 'Er zijn geen foto\'s in dit album';
} else {
        foreach ($albums as $album) {
                $image = true;
        foreach ($images as $image) {          
                echo'<a href="view_album.php?album_id=', $album['alb_id'],'&image_id=uploads/', $image['album'], '/', $image['id'], '.', $image['ext'], '"><img src="uploads/thumbs/', $image['album'], '/', $image['id'], '.', $image['ext'], '" title="" /></a><a href="delete_image.php?image_id=', $image['id'],'">x</a> ';
                $image = false;
        }
        if(!$image) break;     
        }
}
?>
</div>
<div id="imagecontainer">
  <div id="image">
<?php	
	$image = (int)$image;
	$full_image=(isset($_GET['image_id'])) ? $_GET['image_id'] : (int)$images[0];
	var_dump($images);
echo'<a href="?image_id=uploads/', $image['album'], '/', $image['id'], '.', $image['ext'], '"><img src="',htmlentities($full_image), '" title="" />';
?>

After $image = false; I try to change the $image variable in an integer. I hoped that I could use the $image variable again but it is not working.

I hope you can help me out here, thanks.
http://www.robcnossen.nl/view_album.php?album_id=7

Re: photo gallery

Posted: Tue Jan 29, 2013 7:45 am
by jacek
Sorry for the delay, it looks like you worked it out though :D ?

Re: photo gallery

Posted: Wed Jan 30, 2013 10:02 am
by Robbedoesie
He Jacek,
Sorry for the delay, it looks like you worked it out though :D ?
no problem, I hope you are alright.

I recently find out that the problem was not with the images but with the albums. I find that out when I added another album, so I had then four albums instead of three albums and suddenly I had four thumbnails of each image instead of three thumbnails of each image.
At first I didn't made a link between the amount of albums and the same amount of thumbnails, but after adding the fourth album I did.
Still it took a while before I could solve this problem but finally I did :D .
this one line solved the thumbnail problem;
if ($image['album'] === $album['id'])
.

Now this is settled I hope it is easier to find the image source for showing an image immediately after opening the image gallery page. If I think am not able to solve this problem I come back to your forum.

Re: photo gallery

Posted: Fri Feb 01, 2013 3:53 pm
by Robbedoesie
well, I am not get the problem solved as how I want it to.
I can get now show an image immediately after opening the image gallery page, but the problem now is that it won't go away when I click on a thumbnail. So there are two images sort of fighting for one spot.
http://www.robcnossen.nl/view_album.php?album_id=7
This is the code what belongs to this;
$full_image=(isset($_GET['image_id'])) ? $_GET['image_id'] : (isset($images['img_name'])); 
echo'<a href="?image_id=uploads/', $image['album'], '/', $image['id'], '.', $image['ext'], '">

<img src="uploads/' ,$image['album'], '/' ,$image['id'],  '.' ,$image['ext'],htmlentities($full_image), '" title="" />';
I am trying to solve this problem with for example this;
if(isset($_GET['image_id'])){
	$full_image = $_GET['image_id'];
		
}elseif(isset($images['img_name'])){
	$full_image = $images['img_name'];
	//break;
}
$full_image = (isset($images['img_name'])) or (isset($_GET['image_id']));
echo'<a href="?image_id=uploads/', $image['album'], '/', $image['id'], '.', $image['ext'], '">
<img src="uploads/' ,$image['album'], '/' ,$image['id'],  '.' ,$image['ext'],htmlentities($full_image), '" title="" >';
I thought that if I break after $images['img_name']; that this part was taking place for $_GET['image_id'];. But the $images['img_name']; part is now staying at his place, there is no place at all for another image, if I break or not it makes no difference.

Am I on the right track to solve this problem, what am I doing wrong here?
Thanks...

Re: photo gallery

Posted: Sun Feb 24, 2013 2:02 pm
by jacek
Robbedoesie wrote:Am I on the right track to solve this problem, what am I doing wrong here?
Basically no. $images is not defined at the point you are trying to use it.