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-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


All times are GMT. The time now is 10:15 AM.

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.01366 seconds
  • Memory Usage 1,764KB
  • 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
  • (5)bbcode_code_printable
  • (1)bbcode_html_printable
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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