WordPress.org

Ready to get started?Download WordPress

Forums

Resize Image After Upload
[resolved] Works only with admin role? (15 posts)

  1. Metrokitman
    Member
    Posted 1 year ago #

    Hi.

    Just tried this plugin when logged in with an admin role. Upload of jpg-files worked fine, all scaled to desired max values.
    Then I tried the very same thing (same files) logged in as an author and the upload did not work at all. Instead I keep getting an error message:

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 3356 bytes) in /www/htdocs/w0102e8f/wordpress/wp-content/plugins/resize-image-after-upload/class.resize.php on line 183

    Then: plugin deactivated, author upload working again, but without being able to control the image size.
    Q: Is there a connection between roles and the capacity of this plugin? Sounds funny, but that's what it looks like to me. Thing is: I mainly need this plugin for those with author roles. Am I able to incorporate the authors?

    Any hints greatly appreciated, many thanks.

    http://wordpress.org/extend/plugins/resize-image-after-upload/

  2. Metrokitman
    Member
    Posted 1 year ago #

    Never mind. Changed to another plugin that works.

    Thanks.

  3. JEPSONRAE
    Member
    Plugin Author

    Posted 1 year ago #

    Hi, the error message you were receiving is a PHP error - nothing to do with admin roles. You needed to provide PHP with more memory to allow it to perform the image resizing processes. From the error message, you seem to have around 64MB provided to PHP, updating it to 512MB should be more than enough.

    Here's a guide on how to do this: http://www.dailyblogging.org/wordpress/increase-wordpress-memory-limit/

  4. obendi
    Member
    Posted 9 months ago #

    Hi,

    I have the same case. If I'm logged in with an administrator role, everything works fine, but if I'm logged in with an editor role, I get the same error of allowed memory.

    My server has a memory_limit = 48M.
    Is it not enough to resize an image of 1.5MB?
    With administrator user I uploaded images up to 5MB (not tried larger images).

    Anyway, why is working with users with administrator role and isn't working with users with different roles than administrator?

    Thanks.
    Regards.

  5. JEPSONRAE
    Member
    Plugin Author

    Posted 8 months ago #

    Hi,

    The resizing process actually uses a considerable amount of memory to perform. This is purely a PHP issue with the GD image manipulation library so is outwith our control.

    In terms of working with images, it's not really the filesize that matters, but more the pixel dimensions. I'm guessing this is because PHP will take the uploaded JPEG image (i.e. 1.5MB), convert it into a standard bitmap (i.e. 50+MB), then perform the resize and save it down as a newly compressed JPEG. I don't know that for a fact, but this is my best guess. As a test, you can try opening your 1.5MB JPEG in Photoshop and just save it as a BMP file - I'm sure the resultant file size will be near or in excess of the available memory on your server.

    The reason that it's only happening for your editor user may be that memory is being allocated to other operations that run for the editor and not the admin; therefore meaning there is less left for image manipulation. Or... the images you've uploaded as an editor decompress into much larger images than the ones you tested with the administrator role.

    Hope that helps,
    Phil

  6. yedidel
    Member
    Posted 8 months ago #

    Hi,

    I am having the same problem. This does not have anything to do with memory since admin role runs a log more operation than editor role. Also increasing memory for PHP didn't change anything.

    It seems there is a bug that blocks the resizing when not logged in as administrator

  7. JEPSONRAE
    Member
    Plugin Author

    Posted 8 months ago #

    What did you increase your memory limit too and what size (both filesize and pixel dimensions) was the image you were trying to upload?

    There is nothing different that this plugin does under the editor role then under the admin role, and it works fine for us here in testing and in live environments. All our clients manage their websites as editor roles and none of them have memory issues. They do however run their sites on our own server which provides an adequate 512MB of memory to each site.

    If there is some underlying memory issue with editor roles then it's with WordPress itself, not this plugin I'm afraid.

  8. obendi
    Member
    Posted 8 months ago #

    Hi,

    Finally I've added the next line in .htaccess file and it works fine for every role:
    php_value memory_limit 128M

    Regards.

  9. JEPSONRAE
    Member
    Plugin Author

    Posted 8 months ago #

    Great, glad it's sorted.

  10. mljenkins
    Member
    Posted 8 months ago #

    This is driving me NUTS! I have the same issue with the plugin. As an author or editor, after dragging a 4 MB JPEG onto the media window I get "Error demo2.jpg An error occurred in the upload. Please try again later."

    I attempted to increase the php.ini from 64 MB upload_max_filesize and post_max_filesize to 128 MB and it still won't work. I do not see any errors in the php error_log file.

    The exact same file uploads fine if the user is an administrator. So I tested this to make sure I wasn't crazy. The user has author permission. On one screen I am logged in as admin starring at the user's profile. On another screen, I am logged in as the user that is an author. On the author's screen, I drag a JPEG file over (4 MB in size) and receive the error. I on the administrator screen, I change the author user to an administrator. I go back to the author's screen (who now has admin rights), drag the same file over, and it works perfect! I never even had to log out and back in as the author user!

    I thought it may have something to do with the max image size set in wordpress so I verified the max image dimensions were larger than the auto resizer image dimensions.

    The plugin works awesome as an administrator, but I can't figure out what is going on with the other roles. Some hints on where to check for more information on the error would be greatly appreciated!

    Thanks a ton!

  11. mljenkins
    Member
    Posted 8 months ago #

    Well I finally figured out where my PHP logs were going for the plugin and low and behold I feel pretty silly now.

    [20-Nov-2013 00:30:08] PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 13056 bytes) in /home/acme/public_html/wp-content/plugins/resize-image-after-upload/class.resize.php on line 183

    Somehow I had gotten distracted by another forum yesterday where people were referring to the max upload size. Apparently I was too tired to read that people in this forum were talking about the PHP memory_limit variable. Ugh. I should have drank more caffeine before giving up!!

    So, yes this is definitely the fix. I am on hostgator and I have SSH access so I just opened php.ini in my public_html directory using vim and quickly changed the value.

    Thanks for everyone that corresponded here for those of us that may fight this in the future!

  12. JEPSONRAE
    Member
    Plugin Author

    Posted 8 months ago #

    @mljenkins
    Glad you got it sorted. Indeed it is the memory_limit that needed increasing; although the maximum post size also needs to be larger than the uploaded image - but that would have failed during upload, not resizing and I think WordPress would have told you in a nice error message (as opposed to a nasty PHP error message).

  13. leroypatches
    Member
    Posted 4 months ago #

    @mljenkins

    Hi,
    Thanks for all the posts. Having the same problem. Could you please explain what I need to do, me being someone with only a working knowledge of this kind of stuff.

    I tried adding php_value memory_limit 128M to the .htaccess file through cpanel like obendi above suggested but it didnt work (may have put it in wrong place.)

    Not sure how to go about doing your fix.
    Any help greatly appreciated,
    Thanks

  14. mljenkins
    Member
    Posted 4 months ago #

    If you are on hostgator, the php.ini file will be in your public_html wordpress directory. This could be ~/public_html/wordpress/php.ini or ~/public_html/php.ini. It depends on where you installed WordPress.

    Open that file and you should see somewhere in there a line such as:
    memory_limit = 64M

    You need to edit the php.ini and change the value to 128M, for example:

    memory_limit = 128M

    I apologize for the late response, it has been a busy week. I know how much of a headache it can be to resolve these things, so I wanted to get back to you in case you hadn't found the solution yet.

    Matt

  15. leroypatches
    Member
    Posted 3 months ago #

    Hey,
    Thanks a mil for the help. A friend of mine found this thread and only for that and your help I would be still at it.
    Thanks a mil,
    Brian

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.