Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Limit Signature Image Size in kilobyte
#1
Create limitsign.php in Notepad ++

and copy (or you can use attached file)

<?php 
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

// Plugin info
function limitsign_info ()
{
	return array(
		"name"			=> "limitsign",
		"description"	=> "limitsign",
		"website"		=> "limitsign",
		"author"		=> "limitsign",
		"authorsite"	=> "limitsign",
		"version"		=> "limitsign",
		"guid" 			=> "limitsign",
		"compatibility" => "16*"
	);
}

$plugins->add_hook('usercp_start', 'signsize');
function signsize()
{
    global $mybb, $error;

    preg_match_all("/\[img(.*?)\](.*?)\[\/img\]/i", $mybb->input['signature'], $matches, PREG_SET_ORDER);

	$kbsizetot = 0;
	
	foreach ($matches as $img)
	{
	$kbsize = strlen(@file_get_contents($img[2]));
	$kbsizetot += $kbsize;
	}
    
    if (($kbsizetot > 350000) && ($mybb->input['action'] == "do_editsig")) {

    $error = inline_error("The sum of the size of the images exceeds the allowed limit of 350kb.");

    }	
}
?>

Change "350000" with value you want...
350000 is same 350 kb
100000 is same 100 kb.....

Change "The sum of the size of the images exceeds the allowed limit of 350kb." with error message you want.

upload limitsign.php to plugin folder and activate.
it´s all.


Attached Files
.php   limitsign.php (Size: 1.04 KB / Downloads: 96)
Reply
#2
New version.

code is now better.
now works with any number of image in the signature.

If you use old code, plz change with this new.

Thanks.
Reply
#3
maybe should be a core feature! Wink
[MyBB 1.8 Czech translation] [MyBB 1.8 plugins]: Prune old PMs + optimize DB plugin --- Thank you/like system
Reply
#4
(06-22-2014, 03:13 PM)Eldenroot Wrote: maybe should be a core feature! Wink
agree
Reply
#5
Been looking for this for ages with no luck, works really well, thanks!
Reply
#6
awesome plug bro ty so much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)