Version: 1.00, by Zzed
Developer Last Online: Feb 2012
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]!=0 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]==0 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]==0 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.
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!
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...