Member
Member
developing   2008-12-15, 22:52
#1
Im trying to have a random image show up on my homepage, but i want it to link to the actual image page it is contained on but it keeps reloading the page here is the code:

<?php $counter = 1;
while (next_album() and $counter == 1): ?>
<a>" title="<?php echo getAnnotatedAlbumTitle();?>">
<?php makeImageCurrent(getRandomImages()); printDefaultSizedImage(getImageTitle());?></a>
<?php $counter++;
endwhile; ?>
Member
Member
sbillard   2008-12-15, 23:42
#2
What is the while loop for? As coded it only loops once, so seems somewhat redundant.

Also, your code must not be complete--as shown above there are some dangling constructs. To show code on this forum you should enclose it in 'peck' marks. (On a US PC keyboard that is the character below the tilda on the left end of the numeric key row.)

Anyway, somewhere there would need to be the href link to the image page.
Member
Member
developing   2008-12-16, 01:45
#3
Im still getting to grips with php, i removed the loop now, but it still goes to the same album everytime, how do i set it, so that when i click on the random image it takes me to the (random generated image) page

`<?php next_album() ?>`
`">`
`<?php makeImageCurrent(getRandomImages()); printDefaultSizedImage(getImageTitle());?>`
Member
Member
timo   2008-12-16, 04:29
#4
Alright, I was doing something similar today, and here's what I came up with:

`<?php $randomImage = getRandomImages(); echo '[img]'.htmlspecialchars($randomImage->getSizedImage(getOption('image_size')) ).'[/img]getTitle(), ENT_QUOTES).'" />';?>`

This should leave a default sized random image linking to it's regular image page. Hope that helps!
Administrator
Administrator
acrylian   2008-12-16, 10:38
#5
You also could have just looked at the existing `printRandomImages()` and could have adapted it since it does not have any size parameters. But it's a good idea, I will add them.
Member
Member
developing   2008-12-16, 19:26
#6
yeah great that works fine now! appreciate
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.