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