4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Holger2 on September 25, 2008, 01:19:35 PM

Title: Req: show newest pic (thumb) on external site
Post by: Holger2 on September 25, 2008, 01:19:35 PM
Hi!

I would like to show the newest pics thumbnails on another, external site.
Is that possible?
I could not find any related topic when searching for this.

/Holger
Title: Re: Req: show newest pic (thumb) on external site
Post by: batu544 on September 25, 2008, 08:44:09 PM
Hi,
    Here is a code .. to get more random images outside the gallery.   ( copyright of this script still belongs to original author..  :)  unfortunately I have forgotten the original Author's name..)

Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: random_more_pics.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;
}

// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images 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."
        ORDER BY a.image_id DESC
        LIMIT 
$num_images";
$result $site_db->query($sql);

while (
$row $site_db->fetch_array($result)){
  
$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 
"&nbsp;&nbsp;<a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"1\" alt=\"$image_name\"></a>&nbsp;&nbsp;";
  echo 
"<b>$image_name</b>\n";
  echo 
"Comments: $image_comments<hr>\n";
}
?>


I think .. you can use this to get the new images thumbnail in external sites.

You can save it in your server and use that link in other websites.


Hope this helps...

Title: Re: Req: show newest pic (thumb) on external site
Post by: V@no on September 26, 2008, 12:35:51 AM
changing
Code: [Select]
        ORDER BY a.image_id DESC
to
Code: [Select]
        ORDER BY a.image_date DESC
should show the latest images.
Title: Re: Req: show newest pic (thumb) on external site
Post by: Holger2 on September 26, 2008, 08:02:23 AM
Great! I will check this out!

V@no: isn't highest ID = newest pic?
Title: Re: Req: show newest pic (thumb) on external site
Post by: Nicky on September 26, 2008, 09:34:50 AM
hi,

DESC is highest ID number = last images
Title: Re: Req: show newest pic (thumb) on external site
Post by: V@no on September 26, 2008, 03:10:37 PM
V@no: isn't highest ID = newest pic?
Image ID means last added image and not necessarily means newest image, because date is what makes an image new or old ;)
Title: Re: Req: show newest pic (thumb) on external site
Post by: webbug on December 23, 2008, 11:48:29 AM
It works great except one condition which I couldnt find a solution to anywhere.

I need to show the new images in the details page.  i.e., details.html in the template.

when i use the new images script in this post inside details.html i get the following error:


Fatal error: Cannot redeclare is_remote() (previously declared in /home/webbug/public_html/v2/photos/includes/functions.php:118) in /home/webbug/public_html/v2/photos/test-new.php on line 37
Title: Re: Req: show newest pic (thumb) on external site
Post by: V@no on December 23, 2008, 03:25:39 PM
You'll need use code started with:

Quote
// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
Title: Re: Req: show newest pic (thumb) on external site
Post by: webbug on December 23, 2008, 03:48:20 PM
You'll need use code started with:

Quote
// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS

You are right! but the only draw back with this code is that you cant specify the number of column you want like the code here:
http://www.4homepages.de/forum/index.php?topic=21956.0

Now I'm really confused! the first code works perfect inside details.html but can't identify the column number whilest the other code have alot of customization but couldnt make it work inside the details.html.

Your kind support again is requested please.
Title: Re: Req: show newest pic (thumb) on external site
Post by: gborislav on May 08, 2009, 10:03:57 PM
Hi,

I just use this script , working but how can i do to open image in new window
Now it opening in same window

Thanks for help.
Title: Re: Req: show newest pic (thumb) on external site
Post by: mawenzi on May 08, 2009, 10:13:36 PM
... find ...
Code: [Select]
<a href=\"".ROOT_PATH."details.php?image_id=$image_id\">

... and replace with ...
Code: [Select]
<a href=\"".ROOT_PATH."details.php?image_id=$image_id\" target=\"_blank\">
Title: Re: Req: show newest pic (thumb) on external site
Post by: gborislav on May 08, 2009, 11:23:18 PM
Hi,

Thanks " mawenzi " works fine.
And I have one more question. It's possible instead of  latest image to show RANDOM image

Thanks again
Title: Re: Req: show newest pic (thumb) on external site
Post by: mawenzi on May 08, 2009, 11:45:46 PM
... find ...
Code: [Select]
ORDER BY a.image_id DESC

... and replace with ...
Code: [Select]
ORDER BY RAND()
Title: Re: Req: show newest pic (thumb) on external site
Post by: gborislav on May 09, 2009, 12:39:45 AM
Thank you, Thank you.