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

Reply
 
Thread Tools
[attachment]id[/attachment] BBcode Details »»
[attachment]id[/attachment] BBcode
Version: 1.00, by Benjy Benjy is offline
Developer Last Online: Nov 2010 Show Printable Version Email this Page

Version: 3.0.3 Rating:
Released: 08-18-2004 Last Update: Never Installs: 8
Template Edits
Re-useable Code Code Changes Additional Files Translations  
No support by the author.

What it does
This hack is a "clone" of the IPB [attachmentid=xxx] BBcode feature. It allows you to insert anywhere in your posts a link to an attachment, using its ID (therefore making it an inline attachment). It also detects the file type and shows either the thumbnail (with a link to the full image), the full image or a text link.
If the attachment doesn't exist or has been moderated, nothing will be shown.
By the way, maybe this should be a VB feature?


What is required
- 1 PHP file edit ("includes/functions_showthread.php")
- 1 CSS style edit
- 1 image upload ("images/misc/inlineattach.gif")


What can be done
- hide the [attachment] BBcode in the search results page
- handle (hide?) the [attachment] BBcode in the printable version
- handle (hide?) the [attachment] BBcode in the archive


Notes
- This hack will add 1 query per attachment BBcode, and the usual amount of queries for the "attachment.php" file call in case of a thumbnail or an inline image.
- The "howto.txt" is provided because it includes the indented code that VB loses with PHP and CODE tags.
- The PSD of the image is provided for personal editing.
- The french version of the image is provided (don't forget to rename it).
- This is my first released hack, so please be cool


Support
I may not be able to provide support for this hack.


Howto (also provided in "howto.txt")
1. Open "includes/functions_showthread.php".

2. Go to (around line 604):
PHP Code:
    $post['message'] = parse_bbcode($post['pagetext'], $forum['forumid'], $post['allowsmilie']);

Add below:
PHP Code:
 //ATTACHMENT BBCODE HACK BEGIN
$post['message'] = preg_replace_callback('#\[attachment\]\s*(\d+)\s*\[/attachment\]#siU''attachment_bbcode_callback'$post['message']);
//ATTACHMENT BBCODE HACK END 
3. Go to (at the end of the file):
PHP Code:
 return "$prepend$text";

Add below:
PHP Code:
//ATTACHMENT BBCODE HACK BEGIN
// ###################### Start attachment_bbcode_callback #######################
function attachment_bbcode_callback($matches)
{
global 
$DB_site$vboptions$bbuserinfo$session$stylevar;
 
$matches[1] = intval($matches[1]);
 
if (!
$vboptions['attachthumbs'] AND !$vboptions['viewattachedimages'])
{
return 
'';
}
else
{
$attachment $DB_site->query_first("
SELECT attachmentid, filename, filesize, IF(thumbnail = '', 0, 1) AS hasthumbnail, thumbnail_filesize, visible
FROM attachment
WHERE attachmentid = " 
$matches[1] . "
"
);
 
if (
$attachment['attachmentid'])
{
if(
$attachment['thumbnail_filesize'] == $attachment['filesize'])
{
    
$attachment['hasthumbnail'] = 0;
    
$attachment['forceimage'] = 1;
}
$attachment['filename'] = fetch_censored_text(htmlspecialchars_uni($attachment['filename']));
$attachment['attachmentextension'] = strtolower(file_extension($attachment['filename']));
$attachment['filesize'] = vb_number_format($attachment['filesize'], 1true);
if (
$attachment['visible'])
{
    switch(
$attachment['attachmentextension'])
    {
     case 
'gif':
     case 
'jpg':
     case 
'jpeg':
     case 
'jpe':
     case 
'png':
     case 
'bmp':
     if (!
$bbuserinfo['showimages'])
     {
     return 
'<img src="' $stylevar['imagesfolder'] . '/attach/' $attachment['attachmentextension'] . '.gif" alt="" title="" width="16" height="16" border="0" /> <a href="attachment.php?' $session['sessionurl'] . 'attachmentid=' $attachment['attachmentid'] . '" target="_blank">' $attachment['filename'] . '</a> (' $attachment['filesize'] . ')';
     }
     else if (
$vboptions['attachthumbs'])
     {
     if (
$attachment['hasthumbnail'])
     {
        return 
'<a href="attachment.php?' $session['sessionurl'] . 'attachmentid=' $attachment['attachmentid'] . '" target="_blank"><img src="attachment.php?' $session['sessionurl'] . 'attachmentid=' $attachment['attachmentid'] . '&stc=1&thumb=1" border="0" alt="' $attachment['filename'] . '" title="' $attachment['filename'] . '" class="inlineattach" /></a>';
     }
     else if (
$attachment['forceimage'])
     {
        return 
'<img src="attachment.php?' $session['sessionurl'] . 'attachmentid=' $attachment['attachmentid'] . '&stc=1" border="0" alt="' $attachment['filename'] . '" title="' $attachment['filename'] . '" class="attach" />';
     }
     else
     {
        return 
'<img src="' $stylevar['imagesfolder'] . '/attach/' $attachment['attachmentextension'] . '.gif" alt="" title="" width="16" height="16" border="0" /> <a href="attachment.php?' $session['sessionurl'] . 'attachmentid=' $attachment['attachmentid'] . '" target="_blank">' $attachment['filename'] . '</a> (' $attachment['filesize'] . ')';
     }
     }
     else if (
$vboptions['viewattachedimages'] == OR ($vboptions['viewattachedimages'] == AND $attachcount == 1))
     {
     return 
'<img src="attachment.php?' $session['sessionurl'] . 'attachmentid=' $attachment['attachmentid'] . '&stc=1" border="0" alt="' $attachment['filename'] . '" title="' $attachment['filename'] . '" class="attach" />';
     }
     else
     {
     return 
'<img src="' $stylevar['imagesfolder'] . '/attach/' $attachment['attachmentextension'] . '.gif" alt="" title="" width="16" height="16" border="0" /> <a href="attachment.php?' $session['sessionurl'] . 'attachmentid=' $attachment['attachmentid'] . '" target="_blank">' $attachment['filename'] . '</a> (' $attachment['filesize'] . ')';
     }
     break;
     default:
     return 
'<img src="' $stylevar['imagesfolder'] . '/attach/' $attachment['attachmentextension'] . '.gif" alt="" title="" width="16" height="16" border="0" /> <a href="attachment.php?' $session['sessionurl'] . 'attachmentid=' $attachment['attachmentid'] . '" target="_blank">' $attachment['filename'] . '</a> (' $attachment['filesize'] . ')';
    }
}
else
{
    return 
'';
}
}
else
{
return 
'';
}
}
}
//ATTACHMENT BBCODE HACK END 
4. Save and upload "includes/functions_showthread.php".

5. Upload "inlineattach.gif" in "images/misc/".

6. Edit your style(s) Main CSS, and add this to your additional CSS (bottom of the page):
Code:
img.inlineattach {
background-color: #336699;
background-image: url('images/misc/inlineattach.gif');
background-position: bottom right;
background-repeat: no-repeat;
margin: 0px 2px 0px 0px 0px;
padding: 2px 2px 14px 2px;
}
(NB: #336699 is the background color of "inlineattach.gif")


Usage
[attachment]id[/attachment]


Demo
Have a look at the attached screenshots.

Show Your Support

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

Comments
  #2  
Old 08-19-2004, 02:42 PM
Polo's Avatar
Polo Polo is offline
 
Join Date: Jun 2004
Posts: 893
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice, will install

Thanks for sharing with the community

*clicks install*
Reply With Quote
  #3  
Old 08-19-2004, 02:56 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

very interesting
Reply With Quote
  #4  
Old 08-19-2004, 05:14 PM
ranger2kxlt ranger2kxlt is offline
 
Join Date: Jan 2003
Location: Plano, TX
Posts: 272
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I like the concept, just afraid my members wouldn't know how to find the ID #....Would there be a way to make a list of the last 15-20 images uploaded with there ID's? Maybe in a pop-up window in the post screen?
Reply With Quote
  #5  
Old 08-20-2004, 01:08 AM
Princeton's Avatar
Princeton Princeton is offline
 
Join Date: Nov 2001
Location: Vineland, NJ
Posts: 6,693
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

good job Benjy :up:

Quote:
I like the concept, just afraid my members wouldn't know how to find the ID #....Would there be a way to make a list of the last 15-20 images uploaded with there ID's? Maybe in a pop-up window in the post screen?
I have a similar BBCODE hack already at http://www.gthelp.com but, it's only for images. (no query).

ranger2kxlt,
To display attachment ID add code into newattachmentbit template (I can't remember if I edited any files to make the below code work):
HTML Code:
<if condition="$attach[extension]=='gif' or $attach[extension]=='jpg'">
         <span class="highlight">[image]$attach[attachmentid][/image]
         </if>
To display the above in newpost_attachmentbit you will need to hack your files.
Reply With Quote
  #6  
Old 08-21-2004, 02:20 PM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

very nice, I'll make some changes (recent uploads or stuff like that) and use it on my forums. Thank you
Reply With Quote
  #7  
Old 09-24-2004, 08:23 PM
Johnny's Avatar
Johnny Johnny is offline
 
Join Date: Jun 2002
Posts: 290
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is their anyway to have it so the attachment box on the postbit doesnt display when using the bbcode.
Reply With Quote
  #8  
Old 10-05-2004, 06:57 AM
Benjy's Avatar
Benjy Benjy is offline
 
Join Date: Nov 2001
Location: France
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This would require to detect the attachment's original postid and tweak a bit more the construct_postbit function...
A very quick solution would be to set $show['attachments'] to false, thus forcing people to add the BBcode into their post. Of course that doesn't work with older posts because it will hide the attachments...
Maybe someone could propose another solution because I don't really have time to get into this for now
Reply With Quote
  #9  
Old 05-16-2005, 08:52 AM
kmike kmike is offline
 
Join Date: Oct 2002
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I wonder if anyone is really using it? Nice hack, but I found a bug where this new bbcode is only being parsed on the 1st post view. Because of this bug, parsed presentation isn't saved to post_parsed table, and consequent views of post will show unparsed [attachment]...[/attachment] code.

The solution is to move line starting with
$post['message'] = preg_replace_callback(...
ABOVE the line starting with
$post['message'] = parse_bbcode($post...
in an original code.

The effect is that attachment bbcode will be parsed before all other bbcodes, and parsed post presentation will be stored correctly afterwards by parse_bbcode() function.

UPDATE: did some testing, the above won't work either. All parsing should be done in parse_bbcode2() from functions_bbcodeparse.php. I was able to fix this, if anyone interested, I can release the necessary updates here.
Reply With Quote
  #10  
Old 05-16-2005, 03:47 PM
YLP1 YLP1 is offline
 
Join Date: Aug 2004
Posts: 417
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have been looking for a way to control how the attachements show in a post...this looks promising.

I have a question on the upload attachments feature with this mod.

This mod looks like the poster must have the url to the attachment and put that url between the attachment bbcode.

Is there a way to use insert the attachment bbcode then click where you want the attachment to be then upload?

Or after the attachment has been uploaded, is there a way to drag that graphic or file or ??? in between the attachment bbcode??

I see this option frequently with other boards (without the use of the bbcode) but I do not know PHP so don't know if this is possible.
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:33 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.05342 seconds
  • Memory Usage 2,356KB
  • 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
  • (1)bbcode_code
  • (1)bbcode_html
  • (4)bbcode_php
  • (1)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
  • (1)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