Author Topic: mas de una imagen aleatoria?  (Read 30831 times)

0 Members and 1 Guest are viewing this topic.

Offline astrock

  • Pre-Newbie
  • Posts: 4
    • View Profile
mas de una imagen aleatoria?
« on: March 29, 2005, 10:20:17 AM »
como puedo extraer imagenes aleatorias para colocarlas en mi pagina WEB principal.

si se puedo, ademas podria imprimir mas de una foto.

Offline excitex2

  • Addicted member
  • ******
  • Posts: 1.590
  • He desactivado la galería y el buscador
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #1 on: March 29, 2005, 01:42:08 PM »
Saludos,,,,

La respuesta la tenías tres post más abajo

Sube este script a tu galería y nombralo por ejemplo :

aleatoria.php

Code: [Select]
<?php 
/************************************************************************** 
*                                                                        * 
*    4images - A Web Based Image Gallery Management System               * 
*    ----------------------------------------------------------------    * 
*                                                                        * 
*             File: random.php                                           * 
*        Copyright: (C) 2002 Jan Sorgalla                                * 
*            Email: jan@4homepages.de                                    * 
*              Web: http://www.4homepages.de                             * 
*    Scriptversion: 1.0 for 4images 1.6.1                                * 
*                                                                        * 
*    Never released without support from: Nicky (http://www.nicky.net)   * 
*                                                                        * 
************************************************************************** 
*                                                                        * 
*    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       * 
*    bedingungen (http://www.4homepages.de/4images/lizenz.php) für       * 
*    weitere Informationen.                                              * 
*    ---------------------------------------------------------------     * 
*    This script is NOT freeware! Please read the Copyright Notice       * 
*    (http://www.4homepages.de/4images/lizenz_e.php) for further         * 
*    information.                                                        * 
*                                                                        * 
*************************************************************************/ 

// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie 
define('ROOT_PATH','./'); 

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

$site_db = new Db($db_host$db_user$db_password$db_name); 
function 
is_remote($file_name) { 
  return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i'$file_name)) ? 0


$sql "SELECT COUNT(*) as total_images 
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b 
        WHERE a.image_active=1 
        AND a.cat_id = b.cat_id 
        AND b.auth_viewcat="
.AUTH_ALL.
        AND b.auth_viewimage="
.AUTH_ALL.
        "

$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 = b.cat_id 
        AND b.auth_viewcat="
.AUTH_ALL.
        AND b.auth_viewimage="
.AUTH_ALL.
        LIMIT 
$number, 1"
$row $site_db->query_firstrow($sql); 
$image_id $row['image_id']; 
$cat_id $row['cat_id']; 
$image_name $row['image_name']; 
$image_comments $row['image_comments']; 
$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"
echo 
"<b>$image_name</b><br>\n"
echo 
"Comments: $image_comments<br>\n"
?>

luego en la web donde quieras que aparezcan la imagen aleatoria inserta un iframe o un include


Code: [Select]
<iframe src="/direccion_del_script/aleatoria.php" width="150" height="150" scrolling="no" frameborder="0"></iframe>
Code: [Select]
<?php include(ROOT_PATH."/direccion_del_script/aleatoria.php"); 

excitex2
Lo importante no es saber,,, lo importante es tener el E-Mail de quien sabe

Offline astrock

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #2 on: April 02, 2005, 12:53:35 AM »
gracias!!!

me fue de mucha ayuda!

Offline tripiyon

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #3 on: October 04, 2005, 04:30:04 PM »
A ver si podéis ayudarme, estoy haciendo lo que digo y me aparece una sola miniatura, como puedo hacer para que se vean más míniaturas en el iframe que estoy creando?
Aparte me aparecen con el nombre de la imagen y en nº de comentarios debajo, como podría quitarlo? Gracias por vuestra ayuda

Offline excitex2

  • Addicted member
  • ******
  • Posts: 1.590
  • He desactivado la galería y el buscador
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #4 on: October 08, 2005, 01:03:45 AM »
Saludos,,,

Para hacer lo que quieres localiza en el script aleatoria.php lo siguiente :

Quote
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 = b.cat_id
        AND b.auth_viewcat=".AUTH_ALL."
        AND b.auth_viewimage=".AUTH_ALL."
        LIMIT $number, 1";

$row = $site_db->query_firstrow($sql);
$image_id = $row['image_id'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$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";
echo "<b>$image_name</b><br>\n";
echo "Comments: $image_comments<br>\n";

?>

Cambiar a :

Quote
for ($i = 0; $i < 3; $i++) {

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 = b.cat_id
        AND b.auth_viewcat=".AUTH_ALL."
        AND b.auth_viewimage=".AUTH_ALL."
        LIMIT $number, 1";

$row = $site_db->query_firstrow($sql);
$image_id = $row['image_id'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$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";
}
?>

excitex2
Lo importante no es saber,,, lo importante es tener el E-Mail de quien sabe

Offline marchoso

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #5 on: March 31, 2006, 04:22:08 PM »
he incluido en el index de mi web fichero index.html el codigo siguiente que si funciona

<iframe src="/phpBB2/4images/ultimas_imagenes.php" width="600" height="200" scrolling="no" frameborder="0"></iframe>

pero cuando me muestra las imágenes me las sigue mostrando en el iframe y me gustaria que fuese en una pagina nueva.

He intentado lo mismo con la siguiente linea:
  <?php include(ROOT_PATH."/phpBB2/4images/ultimas_imagenes.php");
?>

pero no me hace nada, ni error ni nada.

¿que debo hacer para que funcione el include?

Lo que quiero es algo parecido a lo que sale en esta página. http://www.photoshop-designs.com/foro/

Gracias. Benito

Offline excitex2

  • Addicted member
  • ******
  • Posts: 1.590
  • He desactivado la galería y el buscador
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #6 on: March 31, 2006, 08:01:08 PM »
Saludos,,,

Si quieres hacer lo mismo que sale en la dirección que has puesto,,, pon el "iframe· dentro de una tabala.

excitex2
Lo importante no es saber,,, lo importante es tener el E-Mail de quien sabe

Offline marchoso

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #7 on: March 31, 2006, 08:07:21 PM »
muchas gracias, pero cuando pulso sobre una de las imagenes me sigue saliendo en el iframe.

si puedes mira esto   http://www.marchoso.es/prueba.html 

Gracias de nuevo

Offline excitex2

  • Addicted member
  • ******
  • Posts: 1.590
  • He desactivado la galería y el buscador
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #8 on: March 31, 2006, 08:24:38 PM »
Saludos,,,

Localiza en aleatoria.php :

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

Cambia a :

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

excitex2
Lo importante no es saber,,, lo importante es tener el E-Mail de quien sabe

Offline marchoso

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #9 on: April 01, 2006, 11:03:02 AM »
Gracias de nuevo: He cambiado la linea a por esta, gracias a tu ayuda y ahora funciona


echo  "<a target=\"_blank\"  href=\"/phpBB2/4images/details.php?image_id=$image_id\"> <img src=\"".$thumb_src."\" border=\"0\"  bordercolor=\"000000\" alt=\"$image_name\" style=\"border: 1px solid black;\" class=\"imagelink\"><br></center>\n";


Offline tripiyon

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #10 on: May 02, 2006, 11:39:48 AM »
Siento no haber respondido antes, gracias por la info  :D

Offline Flakkk

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #11 on: May 25, 2006, 03:24:54 AM »
Buenas, he leido todo este topic y segun entiendo estos codigos que han insertado arriba es para una web en especial, que codigo tengo que ingresar para que me aparezcan 2 imagenes aleatorias y que 1 de esta este fija y la otra que cambie de fotos cada x cantidad de segundos.

Pido mucho???  :D

Saludos,.

Offline Ers

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #12 on: June 07, 2007, 11:30:21 PM »
Saludos,,,,

La respuesta la tenías tres post más abajo

Sube este script a tu galería y nombralo por ejemplo :

aleatoria.php

Code: [Select]
<?php 
/************************************************************************** 
*                                                                        * 
*    4images - A Web Based Image Gallery Management System               * 
*    ----------------------------------------------------------------    * 
*                                                                        * 
*             File: random.php                                           * 
*        Copyright: (C) 2002 Jan Sorgalla                                * 
*            Email: jan@4homepages.de                                    * 
*              Web: http://www.4homepages.de                             * 
*    Scriptversion: 1.0 for 4images 1.6.1                                * 
*                                                                        * 
*    Never released without support from: Nicky (http://www.nicky.net)   * 
*                                                                        * 
************************************************************************** 
*                                                                        * 
*    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       * 
*    bedingungen (http://www.4homepages.de/4images/lizenz.php) für       * 
*    weitere Informationen.                                              * 
*    ---------------------------------------------------------------     * 
*    This script is NOT freeware! Please read the Copyright Notice       * 
*    (http://www.4homepages.de/4images/lizenz_e.php) for further         * 
*    information.                                                        * 
*                                                                        * 
*************************************************************************/ 

// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie 
define('ROOT_PATH','./'); 

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

$site_db = new Db($db_host$db_user$db_password$db_name); 
function 
is_remote($file_name) { 
  return (
preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i'$file_name)) ? 0


$sql "SELECT COUNT(*) as total_images 
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b 
        WHERE a.image_active=1 
        AND a.cat_id = b.cat_id 
        AND b.auth_viewcat="
.AUTH_ALL.
        AND b.auth_viewimage="
.AUTH_ALL.
        "

$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 = b.cat_id 
        AND b.auth_viewcat="
.AUTH_ALL.
        AND b.auth_viewimage="
.AUTH_ALL.
        LIMIT 
$number, 1"
$row $site_db->query_firstrow($sql); 
$image_id $row['image_id']; 
$cat_id $row['cat_id']; 
$image_name $row['image_name']; 
$image_comments $row['image_comments']; 
$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"
echo 
"<b>$image_name</b><br>\n"
echo 
"Comments: $image_comments<br>\n"
?>

luego en la web donde quieras que aparezcan la imagen aleatoria inserta un iframe o un include


Code: [Select]
<iframe src="/direccion_del_script/aleatoria.php" width="150" height="150" scrolling="no" frameborder="0"></iframe>
Code: [Select]
<?php include(ROOT_PATH."/direccion_del_script/aleatoria.php"); 

excitex2
Este escript me gusta mucho para mostrar una imagen aleatoria,
el problema es que mi galeria es de videos y MP3 y algunos no tienen thumb de modo que los que no tienen imagen en miniatura se ve la típica "X" en lugar de una imagen...
La ruta a la que apunta la X es "data/thumbnails/5/"
¿hay alguna forma de cambiar parte del código para que cuando no haya miniatura se muestre una imagen por defecto y así al menos no sale el error de que no hay imagen disponible?
Si se pudiera solucionar ese detalle el script cumpliria su funcion perfectamente.

Saludos!! :)

Offline tripiyon

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #13 on: May 01, 2008, 01:15:03 PM »
Hola a todos,

He instalado la última versión de la galería y ahora no me muestra las miniaturas en el iframe, tengo que hacer algún cambio en el código de la plantilla aleatoria.php?
Podéis ver el iframe en ESTA PÁGINA donde dice "VISITA NUESTRA GALERÍA"

El código que tengo en la plantilla es el siguiente:

Code: [Select]
<?php
/**************************************************************************
*                                                                        *
*    4images - A Web Based Image Gallery Management System               *
*    ----------------------------------------------------------------    *
*                                                                        *
*             File: random.php                                           *
*        Copyright: (C) 2002 Jan Sorgalla                                *
*            Email: jan@4homepages.de                                    *
*              Web: http://www.4homepages.de                             *
*    Scriptversion: 1.0 for 4images 1.6.1                                *
*                                                                        *
*    Never released without support from: Nicky (http://www.nicky.net)   *
*                                                                        *
**************************************************************************
*                                                                        *
*    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
*    bedingungen (http://www.4homepages.de/4images/lizenz.php) für       *
*    weitere Informationen.                                              *
*    ---------------------------------------------------------------     *
*    This script is NOT freeware! Please read the Copyright Notice       *
*    (http://www.4homepages.de/4images/lizenz_e.php) for further         *
*    information.                                                        *
*                                                                        *
*************************************************************************/

// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH','./');

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

$site_db = new Db($db_host$db_user$db_password$db_name);
function 
is_remote($file_name) {
  return (
preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i'$file_name)) ? 0;
}

$sql "SELECT COUNT(*) as total_images
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
        WHERE a.image_active=1
        AND a.cat_id = b.cat_id
        AND b.auth_viewcat="
.AUTH_ALL."
        AND b.auth_viewimage="
.AUTH_ALL."
        "
;
$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) : 4;

$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 = b.cat_id
        AND b.auth_viewcat="
.AUTH_ALL."
        AND b.auth_viewimage="
.AUTH_ALL."
        LIMIT 
$number, 1";
$row $site_db->query_firstrow($sql);
$image_id $row['image_id'];
$cat_id $row['cat_id'];
$image_name $row['image_name'];
$image_comments $row['image_comments'];
$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\" target=\"_blank\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";
?>

Offline tripiyon

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: mas de una imagen aleatoria?
« Reply #14 on: May 07, 2008, 10:48:48 AM »
Nadie sabe nada?