vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   vBulletin CMS Widgets - Widget: display random image thumbnail from public albums (https://vborg.vbsupport.ru/showthread.php?t=237884)

XManuX 03-08-2010 10:00 PM

Widget: display random image thumbnail from public albums
 
1 Attachment(s)
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.

kevinfx 03-09-2010 09:17 PM

could you make it so that it's possible to display more than 1 pictures?

Videx 03-09-2010 11:43 PM

I was fascinated up to the point I read about having to edit a template. I'd sure hate to have to do that every time I updated and reverted templates.

Dr.osamA 03-10-2010 01:05 AM

installed

thanxxxx

Juggernaut 03-10-2010 02:51 AM

This is nice, is there a way to make the images bigger?

MrBig 03-10-2010 03:45 AM

Demo?

ahmedipa 03-10-2010 03:54 AM

yes , we want demo if there is ?

even screen shot

thank you so much

sean-zigster 03-10-2010 07:29 AM

Is there any way you could make it display from 1 certain album ?

XManuX 03-10-2010 08:02 AM

Hello and thanks for your quick feedback !

As a result, i just updated this mod to v1.1 :

v1.1 :
  • The widget no longer requires template edit of vbcms.css (actually, adding the styling in vbcms.css is an option)
  • More than one thumbnail can be displayed
  • Using the standard vBulletin thumbnail size is also an option : you can use a custom width.

Quote:

Originally Posted by sean-zigster (Post 2000749)
Is there any way you could make it display from 1 certain album ?

Yes, i plan to add this as a new feature soon.

odonel 03-10-2010 12:11 PM

you need to check for empty albums in your sql statement, it is running lots of users with no albums

abroad 03-10-2010 02:35 PM

possible to show them horizontal (e.g. 3 pictures in a row) instead of vertical?

kho91 03-10-2010 05:08 PM

thank you

i have e a sql error:
Table 'dbname.album' doesn't exist

XManuX 03-11-2010 07:38 AM

New version (v1.2) is out.

Quote:

Originally Posted by sean-zigster (Post 2000749)
Is there any way you could make it display from 1 certain album ?

Done in v1.2.

Quote:

Originally Posted by kho91 (Post 2001032)
thank you

i have e a sql error:
Table 'dbname.album' doesn't exist

You probably configured vBulletin to add a prefix to the table names in your database, let me know if version 1.2 solved your problem.

Quote:

Originally Posted by abroad (Post 2000944)
possible to show them horizontal (e.g. 3 pictures in a row) instead of vertical?

I released v1.2 quickly, in order to add some fixes to the database request, so i had little time to add this in the current version. The row/column feature will probably be in the next release of this widget.

Chrissy_Ratbag 03-11-2010 08:02 AM

I have installed this mod. Now, how do I get the album to identify? I have one album only I want it to select from (gallery is the folder name).

And once again, I add a php direct execution widget and get a parsing error of:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/rat10541/public_html/forum2010/includes/class_core.php(4033) : eval()'d code on line 14

XManuX 03-11-2010 08:58 AM

1-Finding the album IDs may be painfull if you are using custom mod rewritted URLs on your website. You can try to navigate to your albums and have a look at the displayed URL in your browser. Most of the time there will be the album ID in it.

Example : album.php?albumid=3 <- 3 is what you are looking for.

2-Regading your error, are-you using the template modification in vbcms.css ?

Chrissy_Ratbag 03-11-2010 09:17 AM

All my images are stored in images/gallery folder

Error - I've not touched a css file, do I need to? I get the same error with all PHP Direct Execution Widgets.

Chrissy_Ratbag 03-11-2010 09:18 AM

<a href="http://ratbags.org.au/forum2010/images/gallery/" target="_blank">http://ratbags.org.au/forum2010/images/gallery/</a>

That is my Gallery folder, I can't see an album id anywhere.

kho91 03-11-2010 09:39 AM

thank you its works for me!

abroad 03-11-2010 09:52 AM

Quote:

Originally Posted by XManuX (Post 2001402)
New version (v1.2) is out.


Done in v1.2.


You probably configured vBulletin to add a prefix to the table names in your database, let me know if version 1.2 solved your problem.


I released v1.2 quickly, in order to add some fixes to the database request, so i had little time to add this in the current version. The row/column feature will probably be in the next release of this widget.

great! You are a hero!

XManuX 03-11-2010 12:38 PM

Quote:

Originally Posted by Chrissy_Ratbag (Post 2001444)
http://ratbags.org.au/forum2010/images/gallery/

That is my Gallery folder, I can't see an album id anywhere.

I don't think that your gallery is made with build-in vBulletin albums feature :)

On a side note : if you get the same error with every widget using direct php execution, it may be a compatibility issue with some custom module.
You may try to disable all the custom modules you've added to your forum and see if widgets are now working.
Then re-enable your modules all by one, checking if it's still working at each module you re-activate. And you'll find the one that is causing you compatibility pbr.

kevinfx 03-13-2010 06:03 AM

it would be great if photos can be displayed in multiple rows & columns :)

ahmedipa 03-14-2010 06:15 AM

so good thank you so much for this

sensimilla 03-18-2010 02:14 PM

Any chance to have better quality of the thumbnail ? TIA

Videx 03-18-2010 05:32 PM

Thumbnails here are perfect, no need to raise quality. None are showing at your link so I'm not sure what your problem may be. Perhaps the original photos are low quality?

Chrissy_Ratbag 03-25-2010 09:48 AM

I don't have custom modules, so what else could be causing the parsing error?

Videx 03-25-2010 11:31 AM

Quote:

Originally Posted by Chrissy_Ratbag (Post 2009923)
I don't have custom modules, so what else could be causing the parsing error?

You have at least one this morning - AddonChat. But I doubt that has anything to do with your problems. It sounds more to me like you may have uploaded your files incorrectly. I'd start over, and this time make sure you don't get core errors before doing any additional work.

Really, you may need to take it to vb.com after you try again, as it doesn't sound like a problem with a modification.

Ocean-Wonders 03-25-2010 04:50 PM

Can this be made to work with vbadvanced ??

munsonfan15 04-11-2010 10:51 AM

Can this be used in the sidebar?

The_____KinG 04-15-2010 05:33 PM

can i use this as forum block ?
how to do that can anybody help please

jimbos'ss 04-21-2010 01:27 PM

can this be made to display left to right instead of up and down?

Bergler 04-23-2010 09:57 PM

Great mod, installed thanks! How would one go about deleting the more.. link? What code do I need to remove? Thanks in advance.

Verionia 04-25-2010 02:56 AM

Can you make it show pictures similar/related to thread/content tags or title? Thx.

pjaco 04-25-2010 09:15 AM

Thanks

Xencored 05-06-2010 01:56 PM

Any chance to have better quality of the thumbnail like the other guy said


Quote:

Originally Posted by Videx (Post 2005969)
Thumbnails here are perfect, no need to raise quality. None are showing at your link so I'm not sure what your problem may be. Perhaps the original photos are low quality?

No all images are fine for me in the right place etc....
quality is set to low somewhere

Also look at the demo image his images look low setting also

goxy63 05-12-2010 11:08 PM

Quote:

Originally Posted by jimbos'ss (Post 2024905)
can this be made to display left to right instead of up and down?

+1

Love this mod, thanks

Karmann 05-16-2010 05:29 PM

Nice one. Thanks.

tommac3 05-21-2010 12:03 AM

How can I make these pics horizontal rather than vertical?

Basically like:

xxx

rather than:

x
x
x

Veer 05-21-2010 01:31 AM

can we have forum block as well?

Blackhat 05-21-2010 02:53 AM

yeah, a forum block would be nice :)

zipperty 05-28-2010 10:12 AM

Thanks for such a great widget. a+


All times are GMT. The time now is 12:41 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01453 seconds
  • Memory Usage 1,856KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (9)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete