PDA

View Full Version : Howto: Attachment icons


Kaitlyn2004
Fri 3rd Aug '07, 10:29pm
When you have an attachments for an issue, if it is an image it can display a thumbnail - otherwise it is just blank. This instead displays an icon for the filetype:

Open pt_attachmentbit and find:
<if condition="$attachment['thumbnail_filesize']">
<a href="projectattachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]" target="_blank"><img src="projectattachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;thumb=1" alt="" border="0" /></a>
<else />
&nbsp;
</if>Replace with:
<if condition="$attachment['thumbnail_filesize']">
<a href="projectattachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]" target="_blank"><img src="projectattachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;thumb=1" alt="" border="0" /></a>
<else />
<img src="images/attach/$attachment[extension].gif" width="16" height="16" alt="" />
</if>If you don't want to display the image, you can always display the icon... replace with this instead:
<img src="images/attach/$attachment[extension]_32.gif" width="32" height="32" alt="" />Finally, create a plugin for "project_issue_attachmentbit" and use this code:
$attachment['extension'] = substr($attachment['filename'], strrpos($attachment['filename'], '.')+1);

DelphiVillage
Mon 6th Aug '07, 6:04pm
that sounds like a bug ? nice catch through

TECK
Tue 7th Aug '07, 2:08pm
It is not a bug. Kaitlyn2004, you should never hardcode the /images/attach folder.
Use the built-in vBulletin variables, instead:
$stylevar[imgdir_attach]

// easier way to grab the extension (and avoid possible file.inc.php formats)
$extension = array_reverse(explode(chr(46), $attachment['filename']));
$attachment['extension'] = $extension[0];

IMO, I think the first post should be at vBulletin.org site instead of here. ;)