PDA

View Full Version : Display a single random image


cferrero
18th of April 2007 (Wed), 10:17
Is there a way of getting EE to display a single random image from its database? I'd like to link to my website using a single random thumb, which rotates per query to EE (i.e. every time the linking page is refreshed).

wcbert33
22nd of April 2007 (Sun), 09:52
Pekka

Yes, I would like to do this feature too.

Bill

jeronimo
22nd of April 2007 (Sun), 14:27
There is a function that can display random images on your site, but probably that is not what you ment?

To do this, you have to add
<?php ee_random_photos("1","thumb"); ?>
on the place that you want (the number show how many thumbs you want (or microtumbs if you change thumb to microthumb) to display)

cferrero
23rd of April 2007 (Mon), 08:31
Not quite what I'm after. I want to put a link on a different website to my EE gallery. The link would make a query to EE and return an image, which I could then use as a clickable link. The details I can code on my own, but first I need a way of getting EE to return the HTTP link to a random image on the server.

jeronimo
23rd of April 2007 (Mon), 09:39
What about the include tag? Then you can make an file on your on server to extract the single thumb, then with include you can include this file to the other site...

check also;
http://photography-on-the.net/forum/showthread.php?t=307163

triadib
30th of April 2007 (Mon), 13:52
Hi,

did you take a look at the snippet solution?

On my homepage (www.my-view.de) I included snippets which links directly to the database and show the latest 5 albums on the right side - 5 random photos are shown on the bottom of the page.
Within the snippet code you can code a minimum of security with hard coding the IP adress which is allowed to call.

1. create a file called random_photo_from_all_exhibitions.php in GALLERY root
2.
<?php

error_reporting(0);

unset($localhost); // IMPORTANT! UNSET ALL CUSTOM VARIABLES YOU USE ON THIS SCRIPT
$localhost = "127.0.0.1/";
clearstatcache();

$get = "random_photos";
$amount = "1";
$exhibition = "all";
$thumbsize = "thumb";
$viewas = "image";
$includecategory = "";
$excludecategory = "";
$thumbclass = "";
$linkclass = "";
@include("./snippets.php");

?>

3. Don't forget to hardcode the allowed IP-adress in snippets.php
4. include the script anywhere in your homepage

If you have further questions - feel free to ask.
Dirk

cferrero
1st of May 2007 (Tue), 09:01
Thanks! Is there a guide to snippets anywhere?

triadib
1st of May 2007 (Tue), 14:21
Look into the GALLERY root directory - Pekka included one file called snippetdemo.php which you can open via browser - there you get a lot of examples and the referring parameter settings.

If you have further problems regarding customizong, tell me what you want and I will take a look...

Dirk

jeronimo
14th of May 2007 (Mon), 18:47
I looked at the snippet stuf also, but one thing I could not manage;
I want to display a single large image on some of my pages for filing it up (pure text is a bit boring for a photo site).

So what I hope to get is some code to display a bigger image with link to the photopage. (eventualy with the photo title also displayed)

MMCM
15th of May 2007 (Tue), 05:23
What about the include tag? Then you can make an file on your on server to extract the single thumb, then with include you can include this file to the other site...

check also;
http://photography-on-the.net/forum/showthread.php?t=307163

I previously used a php (cross domain/server) include with snippets.
The drawback: if the server running EE is down or unreachable for whatever reason, the site using include will have to wait for a timeout for EVERY WEB PAGE.

That's why I switched to an iframe tag, so the client requests the snippets page, and only the iframe will not display, when the EE server is down.

Faustini
11th of September 2007 (Tue), 03:23
Hi triadib!

Regarding your post #6 above, could you please tell me how did you embed those random photos from your EE with thumbs without the typical link-type blue border around them?

Additionally, what should I do so that when the visitors of my website click on any of the thumbs, a new browser page opens and load the specific EE page of the clicked photo?

My EE itself is not embedded or "iframed" within my website (it runs as an external one). I created the "random_photos.php" file into my EE root (according to your given PHP code) and "iframed" it into my website (www.rodrigofaustini.com/index2.html) with the following HTML code:

<iframe src="http://www.rodrigofaustini.com/fotos/random_photos.php" width="100%" height="120" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>

Thank you for any help!

Rodrigo Faustini