WordPress.org

Ready to get started?Download WordPress

Forums

Simple Local Avatars
BUG SIZE IMG (3 posts)

  1. JibsouX
    Member
    Posted 1 year ago #

    there is no limitation for : if the picture uploaded is to big, and it cause fatal error memory... // The image is not bloked and is uploaded

    http://wordpress.org/extend/plugins/simple-local-avatars/

  2. dmagin
    Member
    Posted 1 year ago #

    the problem is not only the KB Size, also if your PHP ini have not to much memory for the process the automatic resize engine in wordpress create the exception.

    i changed one line in the source to limit the heigh and width for the upload in simple local avatars.

    go in the simple-local-avatar.php

    navigate to method: public function edit_user_profile_update( $user_id ) {..
    you find at the end the line:

    update_user_meta( $user_id, 'simple_local_avatar', array( 'full' => $avatar['url'] ) );		// save user information (overwriting old)

    override this line with

    list( $width, $height, $imagetype, $hwstring, $mime, $rgb_r_cmyk, $bit ) = getimagesize( $avatar['url'] );
    			$img_size = get_headers( $avatar['url'],1);
                if(($width * $height > 40000) or (round($img_size["Content-Length"]/1000)>200)) {
                  echo 'Errormessage.......';
                 }
                else {
                  update_user_meta( $user_id, 'simple_local_avatar', array( 'full' => $avatar['url'] ) );		// save user information (overwriting old)
                  }

    i am not a php developer but i fixed this and it works great :-)

  3. JibsouX
    Member
    Posted 1 year ago #

    Hellow thaaannnkk dude !!!

    i have inprove the code you gave me :

    1 : disable 'displaying error' put this after the FIRST '<?php' like this :

    <?php
    ini_set('display_errors','off');
    /**
     Plugin Name: Simple Lo...

    then this is your code with litle tweak ^^:

    list( $width, $height, $imagetype, $hwstring, $mime, $rgb_r_cmyk, $bit ) = getimagesize( $avatar['url'] );
    			$img_size = get_headers( $avatar['url'],1);
                if(($width * $height > 40000) or (round($img_size["Content-Length"]/1000)>200)) {
                  echo '<b style="font-size:35px;">Your avatar is to big, choose another image ! <a href="http://you-domain-name.com/wp-admin/profile.php">// BACK //</a>';
                 }
                else {
                  update_user_meta( $user_id, 'simple_local_avatar', array( 'full' => $avatar['url'] ) );		// save user information (overwriting old)

    VOILA ^^

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.