vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Thumbnail of Attachments on forum display (https://vborg.vbsupport.ru/showthread.php?t=73220)

Dechevious 12-21-2004 10:00 PM

Thumbnail of Attachments on forum display
 
This hack has been requested a number of times, for multiple versions of vBulletin. For whatever reason, it was never done (at least publicly) until now. Heres to wishing each and everyone of you a Merry Christmas, and a prosperous, healthy, and safe, New Year!

What it does: This hack will display a thumbnail of the threads attachment on the forum display. Quite useful if you have forums designated for graphics/photos .. etc. Could also be tweaked to display the posters avatar instead of an attachment. Variable possibilities. (Screenshot attached for further review) and or see it in action at this forum in realtime. If the thread has multiple attachments, it will display the first. If no attachment, a 'no attachment' thumb will appear. Can be assigned for use in any forum you wish it to be active in.

Install time is minimal - Less than 5 minutes for the average joe. (Simplicity at it's Finest)
1 file to modify, and 1 template to modify, along with the upload of an image.

Known Issues: If the attachment is not an image, a thumbnail will not be shown. (IE: .zip or .rar)

If you install it, please click the 'Install' icon - Updates will be sent to those who do.

Erwin 12-22-2004 09:45 PM

Nice idea... I assume this adds only 1 query to forumdisplay?

Dechevious 12-22-2004 09:50 PM

Quote:

Originally Posted by Erwin
Nice idea... I assume this adds only 1 query to forumdisplay?

Actually, it adds no additional query, as it was merged with an existing query.

ChrisSy 12-22-2004 10:05 PM

does this require image software to be running on the server, ie GD image?

Dechevious 12-22-2004 10:20 PM

Quote:

Originally Posted by ChrisSy
does this require image software to be running on the server, ie GD image?

Good question. Yes, it does. You also want to make sure that in your AdminCP you have thumbnails enabled, for those who do not have them already.

lasto 12-22-2004 10:58 PM

how come u released this - considering i just paid for it 2 days ago ?? - it was supposed to of been a custom paid hack ?

Also the files ive downloaded here are the exact as i have from the paid hack

In the readme file it says `Notes: THIS IS A CUSTOM HACK - DO NOT REDISTRIBUTE IT PLEASE!`

Also it has faults - if a rar or zip is attached and not an image u end up in forum display a red X - and so far is no known way to fix it.
If u add multiple attachemnts it used to show all the attachments as seperate posts but not sure if fixed in your version as i was sent an addon to fix this.

Edit ok read the txt file and seems u was the author - but i bet aint the only one to of paid for this - this week.Paid 2 days ago - 2 days later its released lets see if anyone else fell for it.

Dechevious 12-23-2004 12:49 AM

This was always meant to be released. It was a bought hack, the expense was shared, and then it was to be released. Sorry if you felt otherwise, as it was never an issue.

cinq 12-23-2004 03:01 AM

A simple yet great hack, thanks for sharing Dechevious :)

Theater 12-23-2004 03:54 AM

How does it handle multiple attachments? For example if someone posted 5 images on a single posting.

//edit - Also, what about other images posted in the thread besides the first post? Are they displayed somehow as well?

Dechevious 12-23-2004 04:59 AM

Quote:

Originally Posted by Theater
How does it handle multiple attachments? For example if someone posted 5 images on a single posting.

It would display the 1st image in the thread.

Quote:

Originally Posted by Theater
//edit - Also, what about other images posted in the thread besides the first post? Are they displayed somehow as well?

No, simply the 1st attachment.

Sadie Frost 12-23-2004 05:14 AM

I'm having a problem getting the thumbnails to display, and I'm not sure where to look to troubleshoot. The thumbnails display fine in the post, and I have set the forum id in the forumdisplay file. It's showing thumbnail not available for threads without attachments (I believe it's threads that have a threadicon).

I tried removing the last else bit, that shows the threadicon if there is no attachment. Also tried rebuilding thumbails.

Any suggestions?

http://buffy-boards.com/forumdisplay.php?f=19

Edit: I discovered the problem - it was that I needed to have a default icon enabled for the forum. I don't have any idea why that makes a difference...lol...but it does :)

Dechevious 12-23-2004 05:57 AM

Quote:

Originally Posted by Sadie Frost
Edit: I discovered the problem - it was that I needed to have a default icon enabled for the forum. I don't have any idea why that makes a difference...lol...but it does :)

Yes - If a thumbnail does not exist (the thread has no attachment) it is set by default to retrieve an image titled 'nothumb.gif' from your images/misc DIR - I see on your forums your now using the 'clear.gif' (Not a bad choice!) Glad to see it working well for you.

Sadie Frost 12-23-2004 06:07 AM

Thanks for this! I tried for the longest time to code it myself but lol, not a coder :D

I think maybe if you have no set default icon (via your admincp options), you just need to rearrange the conditional in the threadbit template in order to get it to work without having a threadicon specified. Like move that '<if condition="$show['threadicon']">' bit. But I haven't played around with that or anything so I don't know.

Edit:

Okay, yes, if you have no default post icon selected in your admincp, I used this code for the threadbit template and it works:

Code:

<!-- Start: idolpx and dechevious Thumbnail in Forum Display Hack - 20041220 -->
<if condition="$show['threadicons']">

<td class="alt2" align="center" valign="middle">       
<if condition="$displaythumbs">
                            <if condition="$thread['attachmentid']">
                                    <a HREF="attachment.php?attachmentid=$thread[attachmentid]">
                                          <img src="attachment.php?attachmentid=$thread[attachmentid]&stc=1&thumb=1" border=0>
                                </a>
                            <else />
                                <img src="images/clear.gif" width=75 height=56 border="0"></if>
                                                <else /><if condition="$show['threadicon']">
<img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" /></if></td>
        </if>
</if>
<!-- End: Start: idolpx and dechevious Thumbnail in Forum Display Hack - 20041220 -->


cinq 12-23-2004 06:14 AM

Is there a way to check the attachment for its extension ?
Wondering how to get round the non image attachment situation.

Lord Brar 12-23-2004 07:12 AM

oh wow! something i've been dreaming for months... I'll install it once my host move is over :P

Delphy 12-23-2004 12:24 PM

This looks good and I could certainly use it on my forums (http://www.modthesims2.com/)

One thing though I need clarifying: It's mentioned that it takes the first attachment.. what if the first attachment is not an image? Does it display no attachment available?

If so, then would there be a way of looping until it does get the first image available only in the first post on the thread? I'm guessing this would add another query though.

Regards,
Delphy

Dechevious 12-23-2004 12:36 PM

Quote:

Originally Posted by Delphy
This looks good and I could certainly use it on my forums (http://www.modthesims2.com/)

One thing though I need clarifying: It's mentioned that it takes the first attachment.. what if the first attachment is not an image? Does it display no attachment available?

If the attachment is not an image, it will display a red x box (at the moment) trying to find a work around for this. If it has no attachment, it will display a no attachment gif.

Delphy 12-23-2004 06:20 PM

Okay thanks for the reply. I've had a few thoughts about how to achieve this with the minimum of queries, so I'll take a look at the hack :)

MrNase 12-23-2004 06:53 PM

Nice, already had it running at http://www.pagodentreff.de/diskussio...splay.php?f=22 but I never released it because I thought nobody will ever use it :)

Mine chooses randomly from any picture which is attached to the first post.

lasto 12-23-2004 07:14 PM

Quote:

Originally Posted by MrNase
Nice, already had it running at http://www.pagodentreff.de/diskussio...splay.php?f=22 but I never released it because I thought nobody will ever use it :)

Mine chooses randomly from any picture which is attached to the first post.

so what happens on your board m8 if your attachment is a rar - does it display a red X ?

Dechevious 12-23-2004 07:49 PM

Quote:

Originally Posted by lasto
so what happens on your board m8 if your attachment is a rar - does it display a red X ?

At the moment, Yes. We're working to resolve that particular issue.

MrNase 12-24-2004 08:51 AM

Quote:

Originally Posted by lasto
so what happens on your board m8 if your attachment is a rar - does it display a red X ?

Mine is displaying the posticon if there's no screenshot to be shown. This hack is designed to work for only one forum which is an image gallery. Therefore I can make sure any thread has an image :)

Dechevious 12-24-2004 06:45 PM

Quote:

Originally Posted by MrNase
Mine is displaying the posticon if there's no screenshot to be shown. This hack is designed to work for only one forum which is an image gallery. Therefore I can make sure any thread has an image :)

Care to share how you accomplished determining if the file was an image or a zip or rar or any other file, without querying the server to its death?

MrNase 12-25-2004 02:47 PM

Sure ;)

I use the following code:
PHP Code:

                 // Thumbnails
              
if($foruminfo['forumid'] == 22 AND $getpostid $DB_site->query_first("
              SELECT postid FROM " 
TABLE_PREFIX "post WHERE threadid = $thread[threadid] LIMIT 1"))
              {
                  
$attachment $DB_site->query_first("
                  SELECT filename, attachmentid, IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail
                  FROM " 
TABLE_PREFIX "attachment
                  WHERE postid = 
$getpostid[postid]
                      ORDER BY rand() LIMIT 1
                      "
);
                  
$attachmentid $attachment['attachmentid'];
                  
$hasthumbnail $attachment['hasthumbnail'];
                  }
                  
// Thumbnails 

which reads out the attachmentids only from the images which have thumbnails. This excludes all txt or pdf or other files which are not images.
ORDER BY rand() LIMIT 1 tells him to output a randomly chosen attachment.

Together with the following conditional in the threadbit -Template it generates this beautiful gallery :)

HTML Code:

            <if condition="$show['threadicons']">
                    <td class="alt2">
            <if condition="$foruminfo[forumid] == 22 AND $hasthumbnail">
            <img src="attachment.php?attachmentid=$attachmentid&stc=1&thumb=1" /> <else />
        <if condition="$show['threadicon']"><img src="$thread[threadiconpath]" alt="$thread[threadicontitle]" border="0" /><else />&nbsp;</if>
            </if>
            </if>

For some reasons this query doesn't work for any image and I couldn't find out why. But as most of the images work I don't care that much about it. Feel free to take my code and modify it :)

Delphy 12-27-2004 04:42 PM

Okay I've been working on the problem of displaying images regardless of whether the first attachment is an image or not.

The solution I came up with is as follows:

- Keeping the existing $threads SQL query, add the following into it: thread.firstpostid
- Add the following:
Code:

        $displaythumbs = false;
        $forumids = array(41, 42, 43, 44, 45, 46, 47, 48, 49, 69, 70, 40, 50, 51, 52, 97, 98);
        if (in_array($forumid, $forumids)) {
                $displaythumbs = true;
        }

The numbers indicate which forums you want the attachments to be displayed in - as you can see, multiple forums are ok.

- I have to add 1 extra query per forumdisplay page, which is:
Code:

                // Added by Delphy to add proper thumbnails
              if ($displaythumbs == true) {
                        while ($thread = $DB_site->fetch_array($threads))
                        { // AND $counter++<$perpage)
                                $imageposts .= $thread['firstpostid'].",";
                        }

                        if ($imageposts != "") {
                                $imageposts = substr($imageposts, 0, strlen($imageposts) - 1);
                                $sql_images = "SELECT DISTINCT postid,attachmentid FROM attachment WHERE postid IN (0$imageposts) AND thumbnail_dateline > 0";
                                $images = $DB_site->query($sql_images);
                                while ($image = $DB_site->fetch_array($images)) {
                                        $thumbnails[$image[postid]] = $image[attachmentid];
                                }
                                $DB_site->free_result($images);
                                unset($imageposts, $image);
                        }
                }

- Since we've already used a DB_site query, we need to reset the $threads resultset:
Find:
Code:

                while ($thread = $DB_site->fetch_array($threads))
Insert in the line above:
Code:

                $threads = $DB_site->query($sql_threads);
- Within the main while $thread loop that processes the threadbits, add the following:
Code:

                        $thread['attachmentid'] = $thumbnails[$thread['firstpostid']];
The resulting hack can be seen in http://forums.modthesims2.com/forumdisplay.php?f=69

Hope this helps somebody,

Regards
Delphy

lasto 12-27-2004 04:46 PM

any chance of a text file doingthe full install but with these modifciations added because not everyone has added teh 1st version

also m8 the demo on your site gives this error

Unable to add cookies, header already sent.
File: /home/forums/public_html/forumdisplay.php
Line: 806

mhobelsb 12-27-2004 08:18 PM

mhmm... nice hack! :)
but i have a "problem". the nothumb image is displayed but the thumbs are not displayed. get a red cross...

where do i set the default icon via admincp? i don?t find the option...

gd2+ is installed and thumbnails are on.

Delphy 12-27-2004 08:54 PM

lasto, I was probably modifiying it again :)

mhobelsb, using the actual proper hack or my one?

lasto 12-27-2004 09:21 PM

ive removed the attachment hack and will wait for u to do yours delphy as mine is showing red x`s if a rar is added as an attachemnt and it deffos needs a fix

Delphy 12-27-2004 11:22 PM

Okay I've written up a text file in the style of the original, let me know if something doesn't work.

Updated 29th December at 5pm GMT to fix table prefixes and add a line I'd missed out from my original. Should work now :)

Regards,
Delphy

lasto 12-27-2004 11:52 PM

done it right got no errors but even if i upload a pic i still get the No thumbnail is available

Delphy 12-28-2004 01:42 AM

lasto, give me a link to the forum where you did my version of the hack and I'll take a look.

mhobelsb 12-28-2004 05:51 AM

@delphy: just tried your version and, very strange, if i lock now in that forum it says "no entrys in that forum". (but in the stats it still counts the posts and threats)

also tried the one from dechevious and with that i have the problem that the "no thumb pic" is shown but the real thumbs are just red crosses. :)

i want this so much. hope you guys continue work! :) thank you...

Martin

Delphy 12-28-2004 07:04 PM

Are you using table prefixes at all? The quick text file I wrote up didn't have prefixes, so you'll need to edit the SELECT ... FROM attachment to include that.

Sounds like an error in the main SELECT $votequery $previewfield query. The only addition I make is the thread.firstpostid field.

Remember, to install my version you need to REMOVE all traces of the previous thumbnail hack.

mhobelsb 12-28-2004 10:00 PM

ah, yes i used a table prefix. cool, will try it. thanks!!!!

Martin

mhobelsb 12-28-2004 10:14 PM

mhmm... somehow it still donĀ“t work. (maybe i just did the prefix wrong. i have 3dmodeling_ as prefix.. .maybe you can help)

i used a backuped file so there is nothing from previous thumbnail hack...

sorry, maybe i just do something wrong

Martin

Delphy 12-29-2004 02:33 PM

Nah it's probably my fault - I wrote up the text file stupidly early in the morning :)

Any chance I could have a look at your modified forumdisplay?

mhobelsb 12-29-2004 02:47 PM

wrote you a pm with the link. thanks so much for your help and time!

Martin

Delphy 12-29-2004 03:18 PM

Replied with fix and updated the original text file :)

lasto 12-29-2004 04:38 PM

wot was it m8 does the whole hack need redoing or just the forumdisplay bit ?


All times are GMT. The time now is 04:50 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.02225 seconds
  • Memory Usage 1,859KB
  • 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
  • (6)bbcode_code_printable
  • (1)bbcode_html_printable
  • (1)bbcode_php_printable
  • (10)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