PDA

View Full Version : Attachment Descriptions


akanevsky
04-19-2005, 10:00 PM
/*================================================= =====================*\
|| Attachment Descriptions for vBulletin 3.0.7
|| Author : Psionic Vision
\*================================================ ======================*/

What is this:
It enchances attachment upload interface with a new 'attachment description' field :)

Features:
Conveniently enchances attachment upload screen with the description field (see screenshots)
Displays attachment descriptions in:
Attachment Manager, Post Edit (newthread, newreply, editpost) and Attachment List (in posts)

Lizard King
04-20-2005, 09:19 PM
Just a couple questions. Does this add another query also can you give a screenshot off thread with an attachment ?

akanevsky
04-20-2005, 09:22 PM
No, it does not add any additional queries at all :)
Yes, I can post the screenshot. One second please...

EDIT: Screenshot has been added.

nexialys
04-20-2005, 09:59 PM
?: does this work with multiple attachements popup?!...
(when you add the attachments)

akanevsky
04-20-2005, 10:25 PM
It works perfectly with the standard vB3 attachment engine.

Lionel
04-21-2005, 05:08 AM
Dark Visor you are the best. A thousand thank you. The vbulletin developper owe you one. For 2 or 3 years they have been trying to do that one. They even had the unused description field in attachment table. When I questioned them about it, no straight answer could be given.

I installed it, tested, edited deleted, changed attachment in same post, beat it up etc... that description behaved exactly like you said.

For months I have been trying to do this.

One thing, you might want to correct the "alter table add" statement since it is already there. I just replaced the existing varchar with TINYTEXT

For my need, I also placed it under thumbnail, not just the "alt".

Let me bother you with one question, if you are familiar with vbadvanced news.php module. How to display it in front page too?

shiva
04-21-2005, 07:59 AM
Oh My. This could be real handy to say the least. Quick question.

Ability to have multiple fields? I have a lot of file uploads, would be nice to state the author, and a couple other fields.

Also, if there was one thing the attachment system needed, it's the ability to use a URL instead of uploading a file. I have ton's of files needed to be added on my server, and a very slow connection. If you can ever figure that out, many people would be very happy, as it's requested a lot.
Looks awesome.

Ghostsuit
04-21-2005, 01:56 PM
Fantastic idea.

The Realist
04-21-2005, 03:10 PM
Well done.

Ticked install :)

j_86
04-21-2005, 05:15 PM
Incompatiable with the Geek Article System 3.5.0 I think, which makes use of the column "description" in the table attatchments.

Lionel
04-21-2005, 05:17 PM
Incompatiable with the Geek Article System 3.5.0 I think, which makes use of the column "description" in the table attatchments.

negative. I am using it there.

j_86
04-21-2005, 05:24 PM
Both running together well?

Lionel
04-21-2005, 05:26 PM
Both running together well?

Geek placed it in template, but never used that column. He probably provisionned for later. I am going to let him know.

akanevsky
04-21-2005, 05:54 PM
They even had the unused description field in attachment table. When I questioned them about it, no straight answer could be given.

Are you sure about this? I didn't have that field prior to creating the hack.

Let me bother you with one question, if you are familiar with vbadvanced news.php module. How to display it in front page too?

1. Add it into the template - sorry don't have it installed, cannot help you with this.
2. In news.php, find:

iif ($vba_options['portal_news_showattachments'], ', attachment.filename, attachment.filesize, attachment.visible,

replace with:

iif ($vba_options['portal_news_showattachments'], ', attachment.filename, attachment.filesize, attachment.visible, attachment.description,
3. Done.

Ability to have multiple fields?

I assume it would be a good exercise for your finger muscles to manually type whatever you need, as it is not a lot at all.

Also, if there was one thing the attachment system needed, it's the ability to use a URL

This does not have anything to do with the current hack, however, I will look into it.

Geek placed it in template, but never used that column. He probably provisionned for later. I am going to let him know.
I appreciate that :)

Thanks everyone for positive comments :)

j_86
04-21-2005, 06:08 PM
I have it installed, but getting this script error after uploading something:

Line: 337
Char: 273
Unterminated string constant

Line 337 is:
attachlist.innerHTML = "<div style=\"margin:2px\"><img class=\"inlineimg\" src=\"images/attach/rtf.gif\" alt=\"magnetic field questions.rtf\" border=\"0\" /> <a href=\"attachment.php?attachmentid=5&amp;stc=1\" target=\"_blank\">magnetic field questions.rtf</a> (758.2 KB)

Any ideas?

j_86
04-21-2005, 06:09 PM
Geek placed it in template, but never used that column. He probably provisionned for later. I am going to let him know.

The coloumn 'description' already exists on my install, though. I have also seen it as part of the table-installer in GASinstall I think.

akanevsky
04-21-2005, 06:12 PM
Make sure you did everything right. If you get outside the DIV, you get that error...

j_86
04-21-2005, 06:27 PM
Ah, I always put a comment in templates when I use a hack that modifies them, such as;

<!-- attatch descript hack edit above -->

Don't know what template did not like this, but it was one. Removed all comments and working fine :)

Lionel
04-21-2005, 06:29 PM
The coloumn 'description' already exists on my install, though. I have also seen it as part of the table-installer in GASinstall I think.

yes you are right. He added that column, but never used it. I simply altered it from varchar to TINYTXT.

I told him about it so he should not be bothered working on it.

The Geek
04-21-2005, 06:58 PM
The attachemnt description field in gas was provisioned for future release. If you have installed GAS 3.x than you will already have an description field in your attachment table. I hadnt yet put the UI in place for it (and now I dont! :) ). I pushed it into the first 3.0 release so I could import v3articles and keep their descrptions.

This hack should be totally compatible. You may get an error doing an alter table as the column already exists - but everything else should slot in nicely.

Good job - it is a seriously missing element of vB :)

xony
04-23-2005, 02:53 PM
For my need, I also placed it under thumbnail, not just the "alt".


Like put a the description under the image? please it is to me of much utility. Thanks.

akanevsky
04-24-2005, 03:33 PM
UPDATED TO VERSION 1.01
Redo changes in newattachment.php

Ghostsuit
04-25-2005, 11:53 PM
What was the change between 1.0 and 1.01?

akanevsky
04-26-2005, 12:45 PM
Major one - a bug that prevented a _regular_ user to edit his descriptions.

Ghostsuit
04-26-2005, 12:58 PM
Is it just a case of applying the file changes again?

akanevsky
04-26-2005, 05:54 PM
Yeah. Just remove the old pieces of hack code, and add the new pieces instead.

Allan
05-02-2005, 12:14 AM
Work with Geek's article hack ?, no prob ?

akanevsky
05-02-2005, 09:26 AM
Yes.

Allan
05-02-2005, 10:17 AM
Yes.

oki, thanks :)

Samira
05-02-2005, 06:41 PM
For my need, I also placed it under thumbnail, not just the "alt".
Would you mind sharing the code you used for this? The only way I can seem to do it is to have attachments in a vertical line, rather than horizontal, which greatly slows scrolling.

Lionel
05-02-2005, 07:33 PM
I simply placed this in postbit_attachmentthumbnail template <div align="left"> >$attachment[description]</div>

kmike
05-05-2005, 09:05 AM
Small proposal: add another <if> to postbit_attachmentimage, to remove caption tooltip when description is empty.
Also, I added title parameter as it is more standards compliant than ALT (i.e. tooltip will work in Mozilla/Firefox, too).

################################################## ################################################## #######################
# postbit_attachmentimage
################################################## ################################################## #######################

---------------------------------------------------------------------------------------------------------------------------
FIND:
---------------------------------------------------------------------------------------------------------------------------

alt=""

---------------------------------------------------------------------------------------------------------------------------
REPLACE WITH:
---------------------------------------------------------------------------------------------------------------------------

alt="<if condition="!empty($attachment[description])">$vbphrase[attachdescription_caption] $attachment[description]" title="$vbphrase[attachdescription_caption] $attachment[description]</if>"

akanevsky
05-05-2005, 08:55 PM
kmike,

I completely agree with you, thanks for sharing.
I will update the hack with your postbit_attachmentimage later on.

YLP1
05-06-2005, 07:19 PM
I simply placed this in postbit_attachmentthumbnail template
Where should this snippet of code go in this template? <div align="left"> >$attachment[description]</div>

I added a description to test it out on my forum and when I mouseover the graphic I get this:

Description: [ARG:4 Undefined]

Edited to add that I fixed the above..quite by accident LOL

In postbit_attachmentthumbnail my title part looks like this:
title="<phrase 1="$attachment[filename]" 2="$attachment[counter]" 3="$attachment[filesize]" 4="$attachment[description]">$vbphrase[image_larger_version_x_y_z]</phrase>" /></a>

But I still can't get the description to show under the thumbnail...

Any help is greatly appreciated.

akanevsky
05-06-2005, 07:45 PM
It should be:
<div align="left">$attachment[description]</div>
instead of
<div align="left"> >$attachment[description]</div>

YLP1
05-06-2005, 08:52 PM
It should be:
<div align="left">$attachment[description]</div>
instead of
<div align="left"> >$attachment[description]</div>

Yep...I did change that but I still cannot get the description to appear under the thumbnail.

kmike
05-12-2005, 11:06 AM
I have it installed, but getting this script error after uploading something:

Line: 337
Char: 273
Unterminated string constant

Line 337 is:
attachlist.innerHTML = "<div style=\"margin:2px\"><img class=\"inlineimg\" src=\"images/attach/rtf.gif\" alt=\"magnetic field questions.rtf\" border=\"0\" /> <a href=\"attachment.php?attachmentid=5&amp;stc=1\" target=\"_blank\">magnetic field questions.rtf</a> (758.2 KB)
Any ideas?
I got bitten by this, too. It appears IE doesn't like multi-line initializations in Javascript, so every multi-line descriptions will trigger this warning. Also you can 100% trigger this by placing unnecessary new line break in newpost_attachmentbit template.

I got it resolved by rolling back the change in newpost_attachmentbit template. I don't see why it is needed there at all.

akanevsky
05-12-2005, 07:17 PM
I would suggest replacing your newpost_attachmentbit template and newpost_attachment templates to their vBulletin originals. Then this will work.

YLP1
05-12-2005, 11:45 PM
I would suggest replacing your newpost_attachmentbit template and newpost_attachment templates to their vBulletin originals. Then this will work.
I wasn't sure if this post was for me or the one just below mine...but I tried it anyway and I still cannot seem to place the caption of the attachment below the attachment.

Any ideas?

akanevsky
05-12-2005, 11:56 PM
YLP1,

My post was addressed to kmike. About you, well you are placing the code in a wrong place... Place your code outside of the <img ...> tag. Right after it.

YLP1
05-13-2005, 02:24 AM
YLP1,

My post was addressed to kmike. About you, well you are placing the code in a wrong place... Place your code outside of the <img ...> tag. Right after it.
Hi DarkVisor... I am sorry for being so dense with this...

Is this where I am supposed to place this code?

<a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]" target="_blank"> <img class="thumbnail" src="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;stc=1&amp;thumb=1" border="0" alt="<phrase 1="$attachment[filename]" 2="$attachment[counter]" 3="$attachment[filesize]" 4="$attachment[description]">$vbphrase[image_larger_version_x_y_z]</phrase>" /></a><div align="left">$attachment[description]</div>
&nbsp;<if condition="$show['br']"><br /><br /></if>

Putting the code there causes the images (I have the four images on a line setup) to stack one per line...so instead of this:


Example 1
Image ------ Image ------ Image ------ Image
Caption ---- Caption ---- Caption ---- Caption

Which the above is what I am trying to achieve

I get this instead:

Example 2
Image
Caption

Image
Caption

Image
Caption

Image
Caption

How do I get it to look like the example 1?

kmike
05-13-2005, 03:43 AM
I would suggest replacing your newpost_attachmentbit template and newpost_attachment templates to their vBulletin originals. Then this will work.
Err, isn't it exactly what I suggested? And newpost_attachment wasn't changed by your hack, only newpost_attachmentbit.

akanevsky
05-13-2005, 05:49 PM
You would have to use two levels of HTML tables to achieve that result. Are you sure it is worth it?

Acers
05-20-2005, 05:52 PM
is this working for you guys?
me not getting it to work.
following probs in 3.07:

1) in multiple image uploads,, it gives just one description. all other images it discards.. that measn i can enter for only 1 image. Rest are discarded.

2) the image on being uploaded with description is not showing description on main post view page...

akanevsky
05-20-2005, 07:36 PM
This hack works fine on non-hacked boards. I cannot guarantee that it will work otherwise.

Lionel
05-20-2005, 07:52 PM
works fine for me on heavily hacked 3.07

akanevsky
05-20-2005, 08:22 PM
Yes, Lionel, it works for you, but keep in mind that your attachments engine was not hacked prior to installation of my hack. As for this guy, I don't know what he has...

Acers
05-21-2005, 07:57 AM
ok.. got a bit of it fixed up...i had a template problem cos of the other hack.

still not fully working but i guess its a template issue that can be sorted. thanks anyway.. grt hack :)

kmike
05-21-2005, 09:39 AM
Putting the code there causes the images (I have the four images on a line setup) to stack one per line...so instead of this:

Example 1
Image ------ Image ------ Image ------ Image
Caption ---- Caption ---- Caption ---- Caption

Which the above is what I am trying to achieve
.....
How do I get it to look like the example 1?
You'd have to wrap all images in a table. It means an additional change to postbit (or postbit_legacy) template is needed.
But wrapping images in a table also means that the table will be as wide as a sum of images' widths. No overflow would happen if images are too wide, instead, a horizontal scroll would appear. Now imagine someone's uploading five 1024x768 images...

But if thumbnails are enabled, it makes sense to wrap thumbnails in a table. First, you know beforehand a maximum thumbnail width and can control maximum table width therefore. Second, thumbnails in one vertical line look really ugly, taking up too much space and making post too long.

So for these reasons I've made the requested change for thumbnails.
To achieve this, I had to change two templates: postbit (or postbit_legacy) and postbit_attachmentthumbnail.

In postbit template, find this code fragment:

<legend>$vbphrase[attached_thumbnails]</legend>
<div style="padding:$stylevar[formspacer]px">
$post[thumbnailattachments]
</div>

Replace it with:

<legend>$vbphrase[attached_thumbnails]</legend>
<div style="padding:$stylevar[formspacer]px"><table border="0"><tr valign="top">
$post[thumbnailattachments]
</tr></table></div>

Replace whole postbit_attachmentthumbnail template content with:

<td>
<table border="0" cellspacing="0">
<caption align="bottom" style="caption-side: bottom; text-align: left;">$attachment[description]</caption>
<tr><td>
<a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]"><img class="thumbnail" src="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;stc=1&amp;thumb=1" border="0" alt="<phrase 1="$attachment[filename]" 2="$attachment[counter]" 3="$attachment[filesize]" 4="$attachment[description]">$vbphrase[image_larger_version_x_y_z]</phrase>" /></a>
</td></tr>
</table>
</td>
<if condition="$show['br']"></tr>
<tr valign="top"></if>

Acers
05-22-2005, 08:43 AM
guys a bit of help.. i have sorted almost all the rest probs but one thing remain...

when i upload attachments, they are not showing in the main reply thread.. see the image. What could be the prob? It was showing earlier prior to the hack.,
thanks in advance

akanevsky
05-22-2005, 12:12 PM
It might happen when you incorrectly edit one of the templates, used in the hack.

Acers
05-30-2005, 04:58 PM
I checked and rechecked the templates.. esp the newattachmentbit but it still does not get updated real time(that means as soon as attachment is uploaded. However if i do a refresh of the reply page, it comes up properly...
ummm wht you think?

akanevsky
05-30-2005, 05:53 PM
It works on the default styleset, but as I said in the hack description - I do not guarantee it working with alternate styles...

vktechnology
06-03-2005, 03:42 PM
very cool

Megareus Rex
06-03-2005, 10:26 PM
excellent hack!

akanevsky
06-04-2005, 12:05 PM
Thank you :)

mkdevo
06-10-2005, 01:58 PM
can someone verify this? it seems that after installing this, anyone can post attachments in threads, even though i only have attachments enabled for admins..

mkdevo
06-20-2005, 11:53 AM
can someone verify this? it seems that after installing this, anyone can post attachments in threads, even though i only have attachments enabled for admins..

anyone?

akanevsky
06-20-2005, 05:45 PM
Sorry for no reply, have been busy lately.
I have checked - on my board you there is no such bug.. Check that you have done everything correctly. And that your code is not pre-hacked.

WreckRman2
06-29-2005, 02:46 AM
guys a bit of help.. i have sorted almost all the rest probs but one thing remain...

when i upload attachments, they are not showing in the main reply thread.. see the image. What could be the prob? It was showing earlier prior to the hack.,
thanks in advance


Same thing happens on my board...

akanevsky
06-29-2005, 11:12 AM
About the not showing up - I am afraid you posted in a wrong topic, therefore I am not able to reply.

WreckRman2
06-29-2005, 12:56 PM
How is it not the right topic... before the hack as you uploaded attachments in the popup window they would appear in the actual reply to page as shown in the image above. Since the hack the attachments still upload but they do not appear in the reply page in real time.

akanevsky
06-29-2005, 06:48 PM
As I've already mentioned twice, real tiem will only work in default styleset.

WreckRman2
06-29-2005, 11:04 PM
I have the default templates...

Acers
06-30-2005, 11:30 AM
i had the same prob but in my case i had a modified stylesheet.. although had the default templates that this hack modified

kmike
06-30-2005, 11:44 AM
Acers, IndyWebDesign, please see if this fixes your problem:
https://vborg.vbsupport.ru/showpost.php?p=652551&postcount=37

akanevsky
06-30-2005, 11:46 AM
kmike, is that fix in my code? I'll look, thanks.

akanevsky
06-30-2005, 11:50 AM
Try replacing

<if condition="!empty($attach[description])"><br />$vbphrase[attachdescription_caption] <i>$attach[description]</i></if>

with

<if condition="!empty($attach[description])"><br>$vbphrase[attachdescription_caption] <i>$attach[description]</i></if>

It works fine for me... Both in Internet Explorer and Opera

akanevsky
06-30-2005, 11:54 AM
Just checked - it works no problem with this fix, so it shouldnt be that template. What errors do you get?

WreckRman2
06-30-2005, 08:54 PM
In what template?

WreckRman2
06-30-2005, 09:04 PM
Acers, IndyWebDesign, please see if this fixes your problem:
https://vborg.vbsupport.ru/showpost.php?p=652551&postcount=37


Bingo... I reverted the template and made no changes to it at all and it works perfectly now. Thanks!

Acers
07-18-2005, 09:26 AM
perfect for me also.. looked after a long time here ..
thx

yahoooh
08-06-2005, 12:21 PM
great thank

iceman-x
08-28-2005, 08:22 PM
Awesome hack.

I was wondering if its possible to make only one description box ????
3 files and only on description box on the button

I have rewrite the mod so it look like this. We he awesome

akanevsky
08-29-2005, 12:05 PM
I was wondering if its possible to make only one description box ????
3 files and only on description box on the button

Possible, but that's not the way it's designed...

iceman-x
08-30-2005, 11:41 AM
Yes i know. the hack is awsome as it is.
But is there som one that can help me make it to show only one descripton ?

VanAusdal
09-09-2005, 12:31 AM
I am a little fuzzy on how to do the:

>> Setting Install URL: ./admincp/options.php?do=addsetting

Is that done on the php page or is this a command that I run?

Thank you!

VanAusdal
09-09-2005, 09:38 PM
ok I have this working but now it is is having one small problem. If I upload two images, both have descriptions it only shows the description or the second image.

like this:

Image

Image
Description

The description for the first image does not show. What could be wrong?

Phrost
09-15-2005, 04:43 PM
I am interested in possibly using this hack as a part of a step-by-step "how to" article type thread system. Are you still actively supporting this?

Blindchild02
09-16-2005, 08:19 PM
Works like a charm! love it!!

http://www.hulkforum.com/showthread.php?t=11 (attachments in 1st post)

Samira
10-04-2005, 05:18 AM
Any plans to port this to 3.5? My users love it.

akanevsky
10-04-2005, 11:56 AM
Possibly.

Samira
10-25-2005, 09:26 AM
How about if I beg? :cheeky:
/me grins and bats her eyelashes

akanevsky
10-26-2005, 01:18 AM
As there aren't that many installs, I am not going to port this.

Lionel
10-23-2007, 02:38 PM
I ported this to 3.68. Lots of file edits and code changes. If OK with author, I will release it.