XF 2.1 Maximum file size for avatars

slothly

Member
Is there a way to modify the maximum file size in bytes for the avatars? It seems 1MB is the limit and we'd like to raise that.

I've already tried modifying my php.ini file to expand the limit but that didn't seem to do anything.

Alternatively, is there a way for users to provide their avatars with a direct URL instead of uploading it? (if there's an add-on for that, please let me know!)

Thank you
 
Is there a way for users to provide a dynamic link for their avatars instead of uploading it? I am aware of the system where the avatars are uploaded into LQ and HQ formats, but I don't need this for my forum and would like to circumvent it if possible.

Someone on my forum who's active on another forum running on xenforo mentioned that they have the option to provide a link for their avatar without having to worry about file limits. I've looked around for a possible plug-in to accomplish this but I can't find anything.

Any help would be greatly appreciated. I've been trying to figure out a solution to this issue for a month now and can't find any solutions.
 
tenor.gif
 
There is no option for uploading an avatar via a URL.

You can enable Gravatar support should you wish, which will automatically pull avatars for those who have a Gravatar account.
 
Still trying to find the answer to this

GIF avatars over 1mb don't work. If it's under a certain file size, it'll animate.

Is there a way to modify this file size limit for GIF avatars?
 
Last edited:
I'm really not enjoying how every single one of my posts is getting deleted only because you guys can't seem to figure out something that should be very easy to. There was absolutely no inappropriate language in my post, not a single insult or derogatory remark made to anyone in person.
 
Last edited by a moderator:
Often times you can elicit the response you require by replying with some dignity and being polite.

As a specific example:
HELLOOOOOO.

Stop ignoring us only because we're gay, that's homophobic.
Not only does this post start out rather rudely, you go on to cause immense offense to everyone who may be reading by claiming that we're not helping because we are all prejudiced against a specific group of people.

Now, first of all, I'm not sure what would give you the impression that we would even know whether you're gay or not. I had no idea until I viewed the message that we rightly deleted for being obnoxious. Secondly, even if you are gay, I'm not sure how that factors into anything in the slightest.

The second post was deleted because it was, again, quite obnoxious, but it also had some rather odd NSFW references to self-gratification that isn't appropriate for the customers on this forum.

This isn't the way to get support.

If you require a response from a member of staff then you would need to submit a ticket. Otherwise, the lack of response on here may simply mean that no customers have anything further to add.
 
Still trying to find the answer to this

GIF avatars over 1mb don't work. If it's under a certain file size, it'll animate.

Is there a way to modify this file size limit for GIF avatars?
There is no hard upload limit for the file size of avatars. Any size should work as long as PHP and the web server is configured to handle uploads of that size. PHP seems to be configured correctly, based on your screenshot, but sometimes there are web server values and other configurations that can override this.

However, the other issue with animated GIF files is that each GIF would have to be split into each individual frame, each frame would then need to be individually resized, and this process happens four times (four different avatar sizes).

With that in mind, resizing of animated GIFs can be a memory and processor intensive operation that can fail on some servers.

You haven't provided the exact details of any error messages or other symptoms of the avatar upload failing so we'd really be unable to comment further on the cause unless that was clarified.
 
I can't speak for all specific details but sometimes all I get when uploading an animated avatar is following error message:

"Oops! We ran into some problems. Please try again later. More error details may be in the browser console. "

One time, however, I got a more specific error that might be more helpful, although @slothly might have more details about this:

ImagickException: Optimize image layers failed in src/XF/Image/Imagick.php at line 242
  1. Imagick->optimizeimagelayers() in src/XF/Image/Imagick.php at line 242
  2. XF\Image\Imagick->save() in src/XF/Service/User/Avatar.php at line 254
  3. XF\Service\User\Avatar->updateAvatar() in src/XF/Pub/Controller/Account.php at line 466
  4. XF\Pub\Controller\Account->actionAvatar() in src/XF/Mvc/Dispatcher.php at line 321
  5. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 248
  6. XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 100
  7. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 50
  8. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2177
  9. XF\App->run() in src/XF.php at line 390
  10. XF::runApp() in index.php at line 20
333FE37700000578-3543666-image-m-90_1460837123611.jpg
 
If you get the "Oops" error message, it might be worth checking in the browser console.

Is it something that happens nearly instantly or after a period of time? Timeouts could be problematic, especially for GIFs with lots of frames.

The "Optimize image layers failed" message may actually be indicative of a bug in ImageMagick or the Imagick extension. It might be worth seeing if these can be updated on the server as they can sometimes fix unexplained issues.
 
Increasing the PHP memory limit has helped me with resizing larger images in the past. Push it to the max you can, see if it starts working, if it does, you can reduce it again until you hit a spot where it works for the majority of images you think will be resized. Understand some gifs may simply be too big to be resized in this way.
 
There is no hard upload limit for the file size of avatars. Any size should work as long as PHP and the web server is configured to handle uploads of that size. PHP seems to be configured correctly, based on your screenshot, but sometimes there are web server values and other configurations that can override this.

However, the other issue with animated GIF files is that each GIF would have to be split into each individual frame, each frame would then need to be individually resized, and this process happens four times (four different avatar sizes).

With that in mind, resizing of animated GIFs can be a memory and processor intensive operation that can fail on some servers.

You haven't provided the exact details of any error messages or other symptoms of the avatar upload failing so we'd really be unable to comment further on the cause unless that was clarified.
First off, I want to say thank you for taking the time to help! I really appreciate it, this issue has been plaguing me for months and it has been frustrating not being able to find a solution after endless research.

I am aware of the process of resizing the avatars into four different avatar sizes and understand that it's hard-coded into the software. However, is it possible to disable this process? Would it help solve the problem? We really only need the avatar in one size to be displayed in the thread, anywhere else is extraneous and I would be fine not showing the avatars in smaller sizes.

@KitHaringtonLover12 provided all of the error messages when one tries to upload an animated avatar over the file size limit.

If you get the "Oops" error message, it might be worth checking in the browser console.

Is it something that happens nearly instantly or after a period of time? Timeouts could be problematic, especially for GIFs with lots of frames.

The "Optimize image layers failed" message may actually be indicative of a bug in ImageMagick or the Imagick extension. It might be worth seeing if these can be updated on the server as they can sometimes fix unexplained issues.
How can I update the ImageMagick extension?

Increasing the PHP memory limit has helped me with resizing larger images in the past. Push it to the max you can, see if it starts working, if it does, you can reduce it again until you hit a spot where it works for the majority of images you think will be resized. Understand some gifs may simply be too big to be resized in this way.

I've tried increasing the PHP memory limit in the past when I read that could be a potential solution, but it didn't seem to change anything... I am not sure if I did it correctly? This is currently what I have configured in my php.ini file:

memory_limit = 64M max_execution_time = 300 extension = "imagick.so" extension = php_gmp.dll extension = php_openssl.dll extension = php_mbstring.dll post_max_size = 600M upload_max_filesize = 600M memory_limit = 600M max_execution_time = 300

Thank you again everyone for helping!
 
Server Error Logs
Stack trace:
#0 src/XF/Image/Imagick.php(242): Imagick->optimizeimagelayers()
#1 src/XF/Service/User/Avatar.php(254): XF\Image\Imagick->save('/home/blingrin/...')
#2 src/XF/Pub/Controller/Account.php(466): XF\Service\User\Avatar->updateAvatar()
#3 src/XF/Mvc/Dispatcher.php(321): XF\Pub\Controller\Account->actionAvatar(Object(XF\Mvc\ParameterBag))
#4 src/XF/Mvc/Dispatcher.php(248): XF\Mvc\Dispatcher->dispatchClass('XF:Account', 'Avatar', Object(XF\Mvc\RouteMatch), Object(ThemeHouse\UIX\XF\Pub\Controller\Account), NULL)
#5 src/XF/Mvc/Dispatcher.php(100): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(ThemeHouse\UIX\XF\Pub\Controller\Account), NULL)
#6 src/XF/Mvc/Dispatcher.php(50): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#7 src/XF/App.php(2177): XF\Mvc\Dispatcher->run()
#8 src/XF.php(390): XF\App->run()
#9 index.php(20): XF::runApp('XF\\Pub\\App')
#10 {main}

Request State:
array(4) {
["url"] => string(25) "/index.php?account/avatar"
["referrer"] => string(52) "https://blingring.club/index.php?threads/1/page-1476"
["_GET"] => array(1) {
["account/avatar"] => string(0) ""
}
["_POST"] => array(7) {
["avatar_crop_x"] => string(1) "0"
["avatar_crop_y"] => string(2) "17"
["use_custom"] => string(1) "1"
["_xfToken"] => string(8) "****"
["_xfRequestUri"] => string(30) "/index.php?threads/1/page-1476"
["_xfWithData"] => string(1) "1"
["_xfResponseType"] => string(4) "json"
}
}

And this is the error I get from the browser console whenever I tried to upload a GIF avatar over the file limit:
index.php:1 Failed to load resource: the server responded with a status of 504 ()
core-compiled.js?_v=be90262e:43 PHP: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>504 Gateway Timeout</title>
</head><body>
<h1>Gateway Timeout</h1>
<p>The gateway did not receive a timely response
from the upstream server or application.</p>
</body></html>

defaultAjaxError @ core-compiled.js?_v=be90262e:43
p @ core-compiled.js?_v=be90262e:40
u @ jquery-3.3.1.min.js?_v=be90262e:2
fireWith @ jquery-3.3.1.min.js?_v=be90262e:2
k @ jquery-3.3.1.min.js?_v=be90262e:2
(anonymous) @ jquery-3.3.1.min.js?_v=be90262e:2
 
A 504 error is a timeout happening on the server side.

All we can suggest is either adjusting the timeouts (probably needs your host/server support to look into it) or uploading a smaller file.

As I said before, updating Imagick etc. may be worthwhile but, again, we can’t provide server support so that would be something you would need to address with your host/server people.
 
I've tried increasing the PHP memory limit in the past when I read that could be a potential solution, but it didn't seem to change anything... I am not sure if I did it correctly? This is currently what I have configured in my php.ini file:

memory_limit = 64M max_execution_time = 300 extension = "imagick.so" extension = php_gmp.dll extension = php_openssl.dll extension = php_mbstring.dll post_max_size = 600M upload_max_filesize = 600M memory_limit = 600M max_execution_time = 300

Thank you again everyone for helping!

I see you have two entries for memory_limit, at the top and 2nd from the bottom. I would suggest removing the 2nd one, memory_limit = 600M and change the top line to memory_limit = 512M.

This may not solve your issue since it appears to be a timeout issue but you shouldn't have two different limits for the same setting.

Assuming it doesn't make a difference keeping it at 128M is probably sufficient.
 
Top Bottom