Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Widget: display random image thumbnail from public albums Details »»
Widget: display random image thumbnail from public albums
Version: 1.2, by XManuX XManuX is offline
Developer Last Online: Nov 2013 Show Printable Version Email this Page

Category: vBulletin CMS Widgets - Version: 4.0.2 Rating:
Released: 03-08-2010 Last Update: Never Installs: 202
Template Edits
Re-useable Code Translations Is in Beta Stage  
No support by the author.

What it does ?
This widget displays a thumbnail image, taken randomly from any public albums and adds a "More..." link redirecting to albums.
Clicking on the thumbnail opens full sized picture in its current album.

Version history :
1.0: Initial release
1.1: Style can now be independant of template modification / Added option to display more than one thumbnail / Added option to define a custom size for the thumbnails.
1.2: You can now restrict picture fetching to a list of albums / Added fixes to the request.

Install instructions :
1- Go in to your AdminCP > vBulletin CMS > Widgets > Create new widget
2- Choose type 'PHP direct execution'
3- Give it a name (i.e: Random Picture)
4- Give it a description (i.e Random picture from public albums)
5- Save it
6- Configure it with the following code (copy/paste)
PHP Code:
// Display random images thumbnails taken from any public albums.
// Author : Sulquendi
// Version: 1.2

// -- Widget Configuration -- 
$use_vB_thumbnail_size     false;
$use_custom_css         false;
$twidth                 190;
$limit                    1;
$albums_list            "";


// -- Nothing to configure below this line --
if ($use_custom_css){
    
$pthumb     'class="pthumb"';
    
$pcaption    'class="pcaption"';
    
$pmore        'class="pmore"';
    
$pstyle        '';
}else{
    
$pthumb     'style="text-align:center;"';
    
$pcaption    'style="text-align:center;font-style:italic;font-family: Times, serif;margin-bottom:10px;"';
    
$pmore        'style="text-align:right;display:block;"';
    
$pstyle        'style="border: 1px solid black;padding:4px;background: white;"';
}
if (
$albums_list!=""$sup_cond "AND alb.albumid IN ($albums_list)"; else $sup_cond ="";
ob_start();
require_once(
DIR '/includes/functions_album.php');
require_once(
DIR '/includes/functions_user.php');
$pic_get vB::$db->query_read("
    SELECT     alb.albumid, att.attachmentid, att.userid, att.caption, att.dateline, att.state, fdt.filesize, IF(fdt.thumbnail_filesize > 0, 1, 0) AS hasthumbnail, fdt.thumbnail_dateline, fdt.thumbnail_width, fdt.thumbnail_height, u.username
    FROM "
.TABLE_PREFIX."album AS alb
    LEFT JOIN "
.TABLE_PREFIX."attachment AS att ON alb.albumid = att.contentid
    LEFT JOIN "
.TABLE_PREFIX."filedata AS fdt ON att.filedataid = fdt.filedataid
    LEFT JOIN "
.TABLE_PREFIX."user AS u ON att.userid = u.userid
    WHERE alb.state = 'public' AND att.contenttypeid = '8' 
$sup_cond
    ORDER BY rand(" 
microtime()*1000000 ") 
   LIMIT 
$limit");
  
$output_bits "";
  while(
$pic vB::$db->fetch_array($pic_get))
  {
    
$albuminfo fetch_albuminfo($pic[albumid]);
    
$picture prepare_pictureinfo_thumb($pic$albuminfo);
    if (
$use_vB_thumbnail_size$size $picture[dimensions]; else $size "width=$twidth";
    
$output_bits .= "<div $pthumb><a href=\"album.php?{$vbulletin->session->vars['sessionurl']}albumid={$pic[albumid]}&attachmentid={$picture[attachmentid]}\"><img $pstyle src=\"attachment.php?{$vbulletin->session->vars['sessionurl']}attachmentid={$picture[attachmentid]}&thumb=1&d={$picture[thumbnail_dateline]}\" alt=\"{$picture[caption_preview]}\" $size /></a>";
    
$output_bits .= "</div><div $pcaption>{$picture[caption_preview]} by {$pic[username]}</div>";
  }
$output_bits .= '<span '.$pmore.'><a href="album.php" alt="To the albums">More...</a></span>';
$output $output_bits;
ob_end_clean(); 
7- There are 5 variables you can edit in this code, to configure the widget behavior :
PHP Code:
$use_vB_thumbnail_size     false;
$use_custom_css         false;
$twidth                 190;
$limit                2;
$albums_list            "1,2,3"
$albums_list :
define a list of albums IDs (coma-separated list) to use, when taking a picture randomly.
You can also specify only one ID.
note: if you leave this variable empty, ALL public albums will be used.

$use_vB_thumbnail_size :
false = the widget will use $twidth to set up the width of the thumbnail.
true = default vBulletin thumbnail size will be used.

$twidth:
Width of a thumbnail (in pixel.)
will only be used if $use_vB_thumbnail_size is set to false.

$limit:
# of thumbnails you want to display in the widget.

$use_custom_css
false = the styling of widget elements will be performed inside the widget itself (using style="" html tag.)
true = the styling will be performed by CSS, thus a template needs to be manually edited : vbcms.css
Code:
.pthumb {
	text-align:center;
}
.pthumb img {
	border: 1px solid black;
	padding:4px;
	background: white;
}
.pcaption {
	text-align:center;
	font-style:italic;
	font-family: "Times New Roman", Times, serif;
	margin-bottom:10px;
}
.pmore {
	text-align:right;
	display:block;
}
8- Your widget is ready to be added to your CMS with AdminCP > vBulletin CMS > Widgets > Layout Manager

Screenshot : see below.

Screenshots

File Type: jpg widgetdemo.jpg (100.2 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Благодарность от:
Haponing

Comments
  #82  
Old 12-05-2011, 05:43 PM
Chadwicksracing Chadwicksracing is offline
 
Join Date: Nov 2011
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by bauers View Post
Hi Chadwicksracing,

please, can you explain me, where I have to edit the code to get the pictures horizontal?

Thanks
Code:
// -- Nothing to configure below this line -- 
if ($use_custom_css){ 
    $pthumb     = 'class="pthumb"'; 
    $pcaption    = 'class="pcaption"'; 
    $pmore        = 'class="pmore"'; 
    $pstyle        = ''; 
}else{ 
    $pthumb     ='style="position: relative;float:left;padding-left:5px;padding-right:5px;padding-bottom:5px;margin-bottom:20px;margin-top:5px;"'; 
    $pcaption    = 'style="text-align:center;font-style:italic;font-family: Times, serif;margin-bottom:10px;"'; 
    $pmore        = 'style="text-align:right;display:block;"'; 
    $pstyle        = 'style="border: 1px solid black;padding:4px;background: white;"';
}
I played with the CSS. Its not perfect, but it does get them into horizontal on my site. I also have this over lapping issue with it.

Reply With Quote
  #83  
Old 12-21-2011, 08:20 PM
Metin-Demirci's Avatar
Metin-Demirci Metin-Demirci is offline
 
Join Date: Nov 2010
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

possible to show them horizontal (e.g. 3 pictures in a row) instead of vertical?
Reply With Quote
  #84  
Old 02-10-2012, 01:56 PM
clubvr4's Avatar
clubvr4 clubvr4 is offline
 
Join Date: Jul 2010
Posts: 116
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Metin-Demirci View Post
possible to show them horizontal (e.g. 3 pictures in a row) instead of vertical?
+1 Please.
Reply With Quote
  #85  
Old 02-13-2012, 08:07 PM
steve k. steve k. is offline
 
Join Date: Dec 2011
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, great widget. works great on 4.1.10. To those who have problems with image not changing: check the configuration of the widget. The is a caching setting set to 5 minutes. If you want the image to change more often then that, you should change that setting. I think that is what happens. I think that will also allow for a "photo of the day" if you set the caching to 1440 minutes. or photoof the week if you go for 10080 minutes.

steve k.
Reply With Quote
  #86  
Old 04-29-2012, 10:50 AM
mgurain's Avatar
mgurain mgurain is offline
 
Join Date: Apr 2005
Location: KSA - Qatif - Al-Jarodiah
Posts: 345
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could this be used in forum sidebar too ? Is it same as CMS widget ?
Reply With Quote
  #87  
Old 05-27-2012, 05:11 PM
Gecuba Gecuba is offline
 
Join Date: Sep 2010
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by mgurain View Post
Could this be used in forum sidebar too ? Is it same as CMS widget ?
Yes, the code could be used for sidebar. Just create new php-block and paste the code in created block.
Reply With Quote
  #88  
Old 08-06-2012, 10:48 AM
nofx1982 nofx1982 is offline
 
Join Date: Feb 2010
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Good!
I'd like to know how to display the latest uploaded picture?
Reply With Quote
  #89  
Old 08-24-2012, 07:56 PM
HondaATC HondaATC is offline
 
Join Date: May 2004
Posts: 96
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great little mod, thanks for sharing!
Reply With Quote
  #90  
Old 09-21-2012, 10:45 AM
Live_Bait Live_Bait is offline
 
Join Date: Mar 2012
Location: Carpentersville IL
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for this! Can anyone show me where to edit to make it so instead of (name of photo) by (name of user) to just > by (name of user)
Some peoples photo names are quite long or just plain strange..
Thank You

I found the line {$picture[caption_preview]} by {$pic[username]}</div>";
I deleated the [caption_preview] so it looks like
{$picture} by {$pic[username]}</div>";

I like it better but on the widget under the photos it now says Array by Live_Bait

I don't mind the word Array but it would be nice if it just said by Live_Bait

Thanks if anybody has the right idea.. I will keep trying myself.

Got it... {$picture [photo]} by {$pic[username]}</div>";
now it just says by Live_Bait

I am sure the word photo could have been any word at all.
Reply With Quote
  #91  
Old 10-10-2012, 07:11 AM
tsafarog tsafarog is offline
 
Join Date: Apr 2009
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nofx1982 View Post
Good!
I'd like to know how to display the latest uploaded picture?
I am interested in that also?

I it possible to display the latest uploaded pics?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:44 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05229 seconds
  • Memory Usage 2,372KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (2)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete