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
  #2  
Old 04-01-2002, 05:53 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Very nice.
Although, I think you should use LENGTH() directly in MySQL as I think it will be faster than catching the data for PHP. And, you should also do this query in showthread.php, in that huge query that gets all the info. That way you don't need to add another query for every attachment you have in the thread. Good job nonetheless!
Reply With Quote
  #3  
Old 04-01-2002, 06:00 AM
Zzed's Avatar
Zzed Zzed is offline
 
Join Date: Feb 2002
Location: Glendale, CA, USA
Posts: 463
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for the kind words and the suggestions.

I feel so honored to be complimented by the great FireFly.

Thanks again.
Reply With Quote
  #4  
Old 04-01-2002, 07:00 AM
Neo's Avatar
Neo Neo is offline
 
Join Date: Oct 2001
Location: Anywhere
Posts: 1,817
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ver nice man... now I need to make my damn attachments hack :O
Reply With Quote
  #5  
Old 04-01-2002, 07:25 AM
Zzed's Avatar
Zzed Zzed is offline
 
Join Date: Feb 2002
Location: Glendale, CA, USA
Posts: 463
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks neo.

BTW, I like the ideas of your current projects. I will be very interested in getting them when you are finished.
Reply With Quote
  #6  
Old 04-02-2002, 04:26 AM
freakyshiat freakyshiat is offline
 
Join Date: Nov 2001
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

works perfect
thanks a bunch
Reply With Quote
  #7  
Old 04-02-2002, 05:59 AM
Zzed's Avatar
Zzed Zzed is offline
 
Join Date: Feb 2002
Location: Glendale, CA, USA
Posts: 463
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're welcome.
Reply With Quote
  #8  
Old 04-02-2002, 02:53 PM
freakyshiat freakyshiat is offline
 
Join Date: Nov 2001
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by FireFly
Very nice.
Although, I think you should use LENGTH() directly in MySQL as I think it will be faster than catching the data for PHP. And, you should also do this query in showthread.php, in that huge query that gets all the info. That way you don't need to add another query for every attachment you have in the thread. Good job nonetheless!
so for every attachment, its adding a query, right?
Do you have a little time to do the coding you explained? If not, its cool...

(Thanks again Zzed)
Reply With Quote
  #9  
Old 04-02-2002, 04:50 PM
Zzed's Avatar
Zzed Zzed is offline
 
Join Date: Feb 2002
Location: Glendale, CA, USA
Posts: 463
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, I revised the code to use the MySql LENGTH() function. I already tested it. Works like a charm.

I have already edited the original post and I have reposted the revised instructions file.
Reply With Quote
  #10  
Old 04-02-2002, 09:53 PM
freakyshiat freakyshiat is offline
 
Join Date: Nov 2001
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Zzed
Ok, I revised the code to use the MySql LENGTH() function. I already tested it. Works like a charm.

I have already edited the original post and I have reposted the revised instructions file.
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 11:06 AM.


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.04982 seconds
  • Memory Usage 2,324KB
  • Queries Executed 23 (?)
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
  • (2)bbcode_quote
  • (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
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)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