Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Attachments show up as links if larger than a certain size. Details »»
Attachments show up as links if larger than a certain size.
Version: 1.00, by Zzed Zzed is offline
Developer Last Online: Feb 2012 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 03-31-2002 Last Update: Never Installs: 2
 
No support by the author.

Note: I have revised this hack to use the MySql LENGTH() function.

This hack alters the attachment view property. If the size of the attached
image is larger than a specified size, the attachment will show up as a
hyperlink as opposed to the actual image.

The size limit for the time being is hardcoded at 50000. I know I should
have made it configurable. My apologies. I will work on it if anyone is
interested.

This hack was requested by Fzale.

Here are the instructions on how to implement it.

In admin/functions.php, look for the following text:
PHP Code:
        if ($post[attachmentid]!=and $post[attachmentvisible]) {
                
$post[attachmentextension]=strtolower(getextension($post[filename]));
                if (
$post[attachmentextension]=="gif" or $post[attachmentextension]=="jpg" or $post[attachmentextension]=="jpeg" or $post[attac\
hmentextension]=="jpe" or $post[attachmentextension]=="png") {
                        if ((
$viewattachedimages) and ($bbuserinfo[userid]==or $bbuserinfo[showimages])) {
                                eval(
"\$post[attachment] = \"".gettemplate("postbit_attachmentimage")."\";");
                        } else {
                                eval(
"\$post[attachment] = \"".gettemplate("postbit_attachment")."\";");
                        }
                } else {
                        eval(
"\$post[attachment] = \"".gettemplate("postbit_attachment")."\";");
                }
        } else {
                
$post[attachment]="";
        } 
And replace it with the following:
PHP Code:
//
// Attachment size hack
//
                        
global $DB_site;
                        
$attachinfo=$DB_site->query_first("SELECT LENGTH(filedata) as ATTLEN from attachment where attachmentid = '$post[attachmentid]'");
                        if(
$attachinfo[ATTLEN] > 50000) {
                                
$ok_to_watch=0;
                        }
                        else {
                                
$ok_to_watch=1;
                        }
                        if ((
$ok_to_watch) and ($viewattachedimages) and ($bbuserinfo[userid]==or $bbuserinfo[showimages])) {
                                eval(
"\$post[attachment] = \"".gettemplate("postbit_attachmentimage")."\";");
                        } else {
                                eval(
"\$post[attachment] = \"".gettemplate("postbit_attachment")."\";");
                        }
                } else {
                        eval(
"\$post[attachment] = \"".gettemplate("postbit_attachment")."\";");
                }
        } else {
                
$post[attachment]="";
        } 
Your feedback will be appreciated.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 07-31-2002, 11:12 PM
Martin64's Avatar
Martin64 Martin64 is offline
 
Join Date: Nov 2001
Posts: 390
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...not good. The number of queries in showthread.php went from 24 to 37
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 04:00 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.04415 seconds
  • Memory Usage 2,232KB
  • Queries Executed 16 (?)
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_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (1)postbit
  • (2)postbit_onlinestatus
  • (2)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete