• [Mod] Random image / Zufallsbild 5 0 5 1
Currently:  

Author Topic: [Mod] Random image / Zufallsbild  (Read 731309 times)

0 Members and 1 Guest are viewing this topic.

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
[Mod] Random image / Zufallsbild
« on: July 12, 2002, 10:43:02 AM »
 :flag-de: hi an alle
 :flag-en: hi all,

 :flag-de: hier ist der Zufallsbild MOD für extra seiten ausserhalb ihrer Gallerie:
 :flag-en: here the Random image MOD for extra sites outside your Gallery:

http://www.nicky.net/4images/random.txt

 :flag-de: speichere den inhalt als random.php
 :flag-en: save the content as random.php

 :flag-de: random.php wurde mit folgenden befehl z.b. in die datei random_mod.php inkludiert
 :flag-en: random.php was included as example into the random_mod.php site with

Code: [Select]
<?php
 
include("./random.php");
?>


 :flag-de: viel spass
 :flag-en: have fun

p.s.:
 :flag-de: vielen dank an JAN der 99% der arbeit geleistet hat ;)
 :flag-en: many thanks to JAN who maked 99% of this mod ;)


# addons for external sites

include thumbail and link on an external site with java script.
http://www.4homepages.de/forum/index.php?topic=1020.msg126303#msg126303

include big image and link on an external site with java script.
http://www.4homepages.de/forum/index.php?topic=1020.msg126326#msg126326
« Last Edit: July 22, 2010, 03:44:53 PM by Nicky »
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline kralle

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #1 on: July 12, 2002, 01:14:57 PM »
Hallo Nicky,

Wenn jetzt allerdings jemand so wie ich die Minniatur in einer kleinen Portalbox per i frame anzeigen lässt, und bei einem klick auf das Minniaturbild nicht die ganze Galerie in dieser Box geöffnet haben möchte, der sollte folgenden HTML Code in der random.php ändern.

Suche:

Code: [Select]

echo "<a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";


Ersetze mit:

Code: [Select]

echo "<a href=\"".ROOT_PATH."details.php?image_id=$image_id\" target=\"_new\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";



Nun sollte die Galerie auf jeden Fall auf einer eigenen Seite öffnen.


Wer die Galerie im selben Browserfenster wie das Portal anzeigen lassen will, der sollte folgenden Code verwenden:


Code: [Select]

echo "<a href=\"".ROOT_PATH."details.php?image_id=$image_id\" target=\"_top\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";



l.g.

kralle

PS: Ein fettes DANKE an Nicky

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #2 on: July 12, 2002, 01:22:34 PM »
*g*

gerne, gerne..

ist ja selbstveständlich..

oder target=\"FrameName\" ;)
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #3 on: July 12, 2002, 05:12:54 PM »
First, thanks to Niky and Jan for this random mod.  It's nice and compact and I think I might use it in other parts of my web site.

But ideally, I'd like to use a random image in a different way.  For my web site home page, I'd like to display a random image.  But instead of displaying the thumbnail and using the random image html template file, I'd like to only display the full image as shown in details.php and I'd like that image to be a link to the details.php page for it.

How would I do this???

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #4 on: July 12, 2002, 06:08:10 PM »
hi chris,

you mean like that
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #5 on: July 12, 2002, 06:24:17 PM »
Yeah, that's it !

Can you post the code for me?

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #6 on: July 12, 2002, 06:29:41 PM »
« Last Edit: December 11, 2007, 05:21:29 PM by kai »
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline dabri

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • http://www.12geschworene.de
Re: [Mod] Random image / Zufallsbild
« Reply #7 on: July 12, 2002, 07:22:21 PM »
Hallo Nicky,

finde diese Funktion Random Image auf anderen seite prima!

Habe die random.php bei mir installiert und funktioniert auch prima, wenn ich diese Datei direkt aufrufe.

Aber sobald ich die random.php in eine bestehende Seite per:

<?php
include("./random.php");
?>

einbinden will, nimmt er immer die relative Adresse vom Thumbnails, von der PHP seite wo ich die random.php include.

Siehe z. B. hier:

http://www.brinkmann-online.de/homepages/bonline/news/news2000.php

In der random.php kann ich im root_path auch keine absolute Adresse eingeben, dann bekomme ich einen Fehler.

Den Link zu details.php habe ich auf der random.php in absolut ändern können, aber nicht zum thumbnail.

Das muss dochirgendwie gehen, ich mach da bestimmt irgendwo einen Fehler?!?

Ich hoffe Du hast mein Kauderwelsch verstanden  :wink:

Gruß Daniel

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #8 on: July 12, 2002, 07:39:04 PM »
wo befindet sich die random.php ?
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #9 on: July 12, 2002, 07:58:47 PM »
okay


probier mal das(E: try this)

in der random.php (E: in random.php)
nach (E: after)
Code: [Select]

include(ROOT_PATH.'includes/constants.php');


füge dies ein (E: add this(ofcourse your own url))
Code: [Select]

define('SCRIPT_URL', 'http://www.brinkmann-online.de/umleitung/4images/');


dann ändere (E: change):
Code: [Select]

$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

echo "<a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";


auf (E: to):
Code: [Select]

$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : SCRIPT_URL.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

echo "<a href=\"".SCRIPT_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline dabri

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • http://www.12geschworene.de
Re: [Mod] Random image / Zufallsbild
« Reply #10 on: July 12, 2002, 08:13:06 PM »
Supi, danke das funktioniert prima!

Das ist hier ein Service - wow!

Nebenbei hab ich wieder mehr erfahren, wie php so finzt

Thx Daniel

Offline timblount

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #11 on: July 12, 2002, 10:28:11 PM »
Can I modify this code to select a random image from just one category of my gallery? If so, how?

Thanks,

Tim

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #12 on: July 13, 2002, 08:40:03 AM »
@timblount
sure!

in the two queries put

Code: [Select]

AND a.cat_id=XXX


XXX = where is your category number
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline timblount

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #13 on: July 22, 2002, 05:27:32 PM »
Hmm I'm not sure what I'm doing wrong.

Here's the code:

$sql = "SELECT COUNT(*) as total_images
        FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
        WHERE a.image_active=1
        AND a.cat_id=2
        AND b.auth_viewcat=".AUTH_ALL."
        AND b.auth_viewimage=".AUTH_ALL."<br>
        ";
$row = $site_db->query_firstrow($sql);
$total_images = $row['total_images'];

mt_srand((double)microtime() * 1000000);
$number = ($total_images > 1) ? mt_rand(0, $total_images - 1) : 0;

$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments
        FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
        WHERE a.image_active=1
        AND a.cat_id=2
        AND b.auth_viewcat=".AUTH_ALL."
        AND b.auth_viewimage=".AUTH_ALL."<br>
        LIMIT $number, 1";

and here's the error:

DB Error: Bad SQL Query: SELECT COUNT(*) as total_images FROM 4images_images a, 4images_categories b WHERE a.image_active=1 AND a.cat_id=2 AND b.auth_viewcat=0 AND b.auth_viewimage=0<br>
You have an error in your SQL syntax near '' at line 7

DB Error: Bad SQL Query: SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments FROM 4images_images a, 4images_categories b WHERE a.image_active=1 AND a.cat_id=2 AND b.auth_viewcat=0 AND b.auth_viewimage=0<br> LIMIT 0, 1
You have an error in your SQL syntax near 'LIMIT 0, 1' at line 7


 :?:

-Tim

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #14 on: July 22, 2002, 07:38:33 PM »
Code: [Select]
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id=2
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."<br>
LIMIT $number, 1";


I don't think the HTML tag <br> belongs in either of the SQL statements.  Try deleting them or download the script again to use the original source code.

 

Post your comments here