Author Topic: Req: show newest pic (thumb) on external site  (Read 14288 times)

0 Members and 1 Guest are viewing this topic.

Offline Holger2

  • Newbie
  • *
  • Posts: 34
    • View Profile
Req: show newest pic (thumb) on external site
« 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

Offline batu544

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Free Celebrity wallpapers
Re: Req: show newest pic (thumb) on external site
« Reply #1 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...

« Last Edit: September 26, 2008, 02:06:09 PM by batu544 »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Req: show newest pic (thumb) on external site
« Reply #2 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.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Holger2

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: Req: show newest pic (thumb) on external site
« Reply #3 on: September 26, 2008, 08:02:23 AM »
Great! I will check this out!

V@no: isn't highest ID = newest pic?

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: Req: show newest pic (thumb) on external site
« Reply #4 on: September 26, 2008, 09:34:50 AM »
hi,

DESC is highest ID number = last images
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 V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Req: show newest pic (thumb) on external site
« Reply #5 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 ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline webbug

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Req: show newest pic (thumb) on external site
« Reply #6 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
« Last Edit: December 23, 2008, 12:12:06 PM by webbug »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Req: show newest pic (thumb) on external site
« Reply #7 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
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline webbug

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Req: show newest pic (thumb) on external site
« Reply #8 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.

Offline gborislav

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Req: show newest pic (thumb) on external site
« Reply #9 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.

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Req: show newest pic (thumb) on external site
« Reply #10 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\">
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 ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline gborislav

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Req: show newest pic (thumb) on external site
« Reply #11 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

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Req: show newest pic (thumb) on external site
« Reply #12 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()
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 ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline gborislav

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Req: show newest pic (thumb) on external site
« Reply #13 on: May 09, 2009, 12:39:45 AM »
Thank you, Thank you.