Author Topic: Random pictures  (Read 229581 times)

0 Members and 1 Guest are viewing this topic.

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: Random pictures
« Reply #135 on: February 18, 2009, 04:30:04 PM »
it will work but only if it picks two images from two different categories. 4images caches one random image for each category.
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 yesme

  • Jr. Member
  • **
  • Posts: 61
  • Yes for 4images!
    • View Profile
Re: Random pictures
« Reply #136 on: February 18, 2009, 04:58:17 PM »
That's mean my random image on the left side will displays same images at one time?! Erm...that is not good.

Btw, if I am using these codes...

Code: [Select]
$cat_in = array(2,7,8,11,12,15,16,18); //list of category ids // *** TO FILTER RANDOM IMAGES ***
...in index.php would be okay? Because I just need the random images display different images at a one time...Any ideas?
Love 4images! @--^-----

Offline Eagle Eye

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: Random pictures
« Reply #137 on: November 23, 2009, 08:06:30 AM »
@V@no

Is it possible to mod this code: http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513 so that it will only randomize the images once in xx hours?

Offline GaYan

  • Sr. Member
  • ****
  • Posts: 301
  • ♫ | G2 | ♫
    • View Profile
    • Ziramagic
Re: Random pictures
« Reply #138 on: November 23, 2009, 02:03:56 PM »
is it possible to show a random image in a external web site ?  8O
I'm Back :)

Rembrandt

  • Guest
Re: Random pictures
« Reply #139 on: November 23, 2009, 02:52:34 PM »
is it possible to show a random image in a external web site ?  8O

FAQ --> http://www.4homepages.de/forum/index.php?topic=1020.0

mfg Andi

Offline Eagle Eye

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: Random pictures
« Reply #140 on: November 24, 2009, 06:39:34 AM »
@V@no

Is it possible to mod this code: http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513 so that it will only randomize the images once in xx hours?


Addition: The reason i think this feature would be useful is because on large websites having lots of images and traffic, randomizing the images each time the page loads will have a huge performance degradation on database server and most shared hosting account will not be allowed to use so much server resources.

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: Random pictures
« Reply #141 on: November 24, 2009, 03:07:41 PM »
@V@no

Is it possible to mod this code: http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513 so that it will only randomize the images once in xx hours?

I've added version B, with cache, in that post
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 Eagle Eye

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: Random pictures
« Reply #142 on: November 26, 2009, 06:33:53 AM »
@V@no

Is it possible to mod this code: http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513 so that it will only randomize the images once in xx hours?

I've added version B, with cache, in that post

Thanks V@no. This is a great addition to this MOD.

I was looking for a different approach, is it possible to cache just the MySQL query results and not generate an individual home page for every new user.... instead just cache the query and write this results in a cache page and serve the same query results to the template engine/php for every user in that time frame.... so what i mean is there will be only one cache file for all users in that time frame....

thank you very much for looking into this.

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: Random pictures
« Reply #143 on: November 26, 2009, 06:36:42 AM »
Your method might conflict with user permissions. What if visitor not supposed to see the cached image?
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 GaYan

  • Sr. Member
  • ****
  • Posts: 301
  • ♫ | G2 | ♫
    • View Profile
    • Ziramagic
Re: Random pictures
« Reply #144 on: May 10, 2010, 06:37:49 AM »
Hey Guys  8O

Can we select the Random Images from a Selected Category and show it on index page ?
I'm Back :)

Offline kangarooms

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Random pictures
« Reply #145 on: July 31, 2013, 07:17:09 PM »
Ich habe versucht es in meine details.html ein zubauen aber es wird mir nichts angezeigt  :cry:

kann mir wer helfen?

Offline praveen

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Random pictures
« Reply #146 on: September 13, 2013, 11:34:39 AM »
Is it possible to show random images from subcategories too?

I have 3 main categories with lots of sub categories.

The main categories do not have any images.  So can the random images be shown from the sub categories?

Offline wallward

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: Random pictures
« Reply #147 on: February 09, 2014, 10:12:37 AM »
thank you V@no
how to exclude some categories?
for example 3 and 16

//------------------------------------
//------- Random Images --------------
//------------------------------------
$num_new_images 8;
$cache_time 360//3600sek = 1hour
$cache_enable_old $cache_enable;
$cache_enable true;
$cache_id_rand create_cache_id(
  
'page.rand',
  array(
    
$user_info[$user_table_fields['user_id']],
    isset(
$user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 08) : 0,
    
$config['template_dir'],
    
$config['language_dir']
  )
);
if (!
$random_images get_cache_file($cache_id_rand$cache_time))
{
  
// Always append session id if cache is enabled
  
$old_session_mode $site_sess->mode;
  
$site_sess->mode 'get';
  
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
          FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
          LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
          WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN ("
.get_auth_cat_sql("auth_viewcat").")
          ORDER BY RAND()
          LIMIT 
$num_new_images";
  
// end new
  
$result $site_db->query($sql);
  
$num_rows $site_db->get_numrows($result);
  
  if (!
$num_rows)  {
    
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  
//  $random_images .= $lang['no_new_images'];
    
$random_images .= "</td></tr></table>";
  }
  else  {
    
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
    
$count 0;
    
$bgcounter 0;
    while (
$image_row $site_db->fetch_array($result)){
      if (
$count == 0) {
        
$row_bg_number = ($bgcounter++ % == 0) ? 2;
        
$random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
      }
      
$random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
  
      
show_image($image_row);
      
$random_images .= $site_template->parse_template("thumbnail_bit");
      
$random_images .= "\n</td>\n";
      
$count++;
      if (
$count == $config['image_cells']) {
        
$random_images .= "</tr>\n";
        
$count 0;
      }
    } 
// end while
  
    
if ($count 0)  {
      
$leftover = ($config['image_cells'] - $count);
      if (
$leftover >= 1) {
        for (
$f 0$f $leftover$f++) {
          
$random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
        }
        
$random_images .= "</tr>\n";
      }
    }
    
$random_images .= "</table>\n";
  } 
// end else
  
$site_sess->mode $old_session_mode;
  
save_cache_file($cache_id_rand$random_images);
}
$cache_enable $cache_enable_old;
$site_template->register_vars(array(
"random_images" => $random_images,
"lang_random_images" => $lang['random_images']
)); 
unset(
$random_images);

//----- End Random Images---------
//------------ End random Image on home page with cache contorol---------

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: Random pictures
« Reply #148 on: February 09, 2014, 01:54:43 PM »
try this in the code:
.....
 
WHERE i.image_active AND c.cat_id i.cat_id AND i.cat_id NOT IN (3,16) AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat").")

Offline Geezer

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Random pictures
« Reply #149 on: May 11, 2015, 07:42:24 PM »
Hallo

gibts solch eine Modifikation auch mit Tageszeit aus nur einer bestimmten Kategorie, zum Beispiel: 6-12 Uhr, 12-18 Uhr, 18-22 Uhr 22-6 Uhr und mit Wochenzeit aus nur einer bestimmten Kategorie (Montag, Dienstag, Mittwoch...... usw.