Support Forum

avatar resizing no longer working

MB Marc Busch
Marc Busch
Member

It seems that my users cannot upload avatars since I moved the site to a new server (at Liquidweb).

They always get an error saying that something went wrong with resizing the image.

The problem is solved by deactivating “Auto resize avatar uploads” in the Forum option.

However, I’d like to have these uploads resized automatically as there will certainly be members who don’t care (or don’t know) about avatar size. :)

It worked well on the previous server.
What could be the reason why the resize option is not working anymore?

Does the resize function require anything specific (except simple press) being installed on the server?

The permission setting of the avatar folder (where the images are stored) is 777 (rwxrwxrwx), so that should not be the problem.

Marc

20 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

I will need to check with Mr Papa who wrote that but I suspect it will require the GD graphics library to be compiled with your PHP. You might like to ask your host if this is present or not…

MP Mr Papa
Mr Papa
Member

you should not have a directory with 0777 – that is risky and could cause server issues…

any errors in the log?  what exactly is the error message…

You say you updated SP, but what version of WP?  The avatar resizing uses functions built into WP…  they are not our own…

MB Marc Busch
Marc Busch
Member

What setting (instead of 0777) should I use for that folder?

The error I get in the forum when the “resize” option is activated is this:

There are few errors in the error log that might be related to this:

The software versions I have installed are:
SP 5.2.6
WP 3.5.2

So, is the “GD graphics library” a possible reason for the problem?

YS Yellow Swordfish
Yellow Swordfish
Member

Best and preferred folder permission setting is 755. Some hosts will not actually serve data if the folder is 777.

Doesn’t seem a GD library issue so that’s OK.

Looks like those errors in your log point to the issue but I am unsure yet what that might be. Will need to do a little code research and possibly wait for Steve (Mr Papa) to arrive on the scene. Seems to be something to do with the avatar file name…

We’ll come back on this asap.

MB Marc Busch
Marc Busch
Member

Thanks. Will change the permission setting…

I get the same error no matter what the filename (unless something is wrong with test.jpg or test.png). I also tried uploading a simple 80×80 pixel white rectangle (filesize < 1kb) as avatar and get the same error.

MP Mr Papa
Mr Papa
Member

you should still check with your host…  wp still needs the GD or ImageMagik library to do its thing..

its a wp function and you would have to do more internal checking to see what the error is…

to get more info, you would need to make a slight code mod and dump the wp error to the screen so we can see what they are complaining about…  up to that?

MP Mr Papa
Mr Papa
Member

find file simple-press/forum/profile/ahah/sp-ahah-profile-save.php…  down around line 348, find this section of code:

                $sfavatars = sp_get_option('sfavatars');
                if ($sfavatars['sfavatarresize']) {
                    $editor = wp_get_image_editor($uploadfile);
                    if (is_wp_error($editor)) {
                        @unlink($uploadfile);
                        $message['type'] = 'error';
                        $message['text'] = sp_text('Sorry, there was a problem resizing the avatar');
                        return $message;
                    } else {
                        $editor->resize($sfavatars['sfavatarsize'], $sfavatars['sfavatarsize'], true);
                        $imageinfo = $editor->save($uploadfile);
                        $filename = $imageinfo['file'];
                    }
                }

after the line

                    if (is_wp_error($editor)) {

add this:

                        ashow($editor);

when you save upload an avatar and it gets resized, this should dump the wp error object to the screen and give more info as to why wp failed to resize it…

MB Marc Busch
Marc Busch
Member

Hmm… doesn’t seem to work.

 

After editing the code and activating “avatar resizing” in the forum options, now nothing happens when I click the “upload avatar” button. Also the (green) error message ‘Sorry, there was a problem resizing the avatar’ does not appear.

Is it possible that ashow($editor); throws an exception?

Any alternative?

MP Mr Papa
Mr Papa
Member

exception? no…

you might need to look at the ajax response in the browser console though..  should have mentioned that.. sorry…

MB Marc Busch
Marc Busch
Member

Hmm…

 

This is what I see in the console when I click the upload avatar button (i.e. nothing happens):

 

There’s no message, also under Errors or Warning sor Debug Info…

 

This is what the edited code looks like:

 

Or am I still looking in the wrong place?

MP Mr Papa
Mr Papa
Member

you have 2 ajax responses there… but they are collapsed… see the  + sign next to the GET?  expand that and see what is reported for response or html… should be something with spdebug…

MB Marc Busch
Marc Busch
Member

OK, so I guess this is what we are looking for… :)

MP Mr Papa
Mr Papa
Member

yes…  so time to ask the host… is GD or ImageMagik compile into your php?