Question

I'm using Wordpress 3.8.1 rus version.

I have custom post types portfolio & slider along with standart posts and pages.

I want to add some additional image sizes to Wordpress for displaying different image thumbnails on website.

So I use this code for adding additional sizes in my functions.php file:

    if ( function_exists( 'add_theme_support' ) ) {
       add_theme_support( 'post-thumbnails' );
       set_post_thumbnail_size( 315, 315, true ); 
     }

    if ( function_exists( 'add_image_size' ) ) {
          add_image_size('portfolio-thumbnail',315, 315, true );
        //add_image_size('slider-thumbnail',350, 150, true );
        //add_image_size('slider-single',700, 370, true );
        //add_image_size('portfolio-article-thumbnail',270, 150, true );
        //add_image_size('article-single',700, 370, true );
          add_image_size('portfolio-single-image', 300, 533, false );
        //add_image_size('portfolio-single-gallery', 72, 72, true );
          add_image_size('portfolio-related-projects', 150, 150, true );
        //add_image_size('portfolio-project-article', 500, 400, true );
        //add_image_size('portfolio-project-article2', 700, 500, true );
        //add_image_size('dimal-single-image', 300, 9999 )
    }

Now I'd explain why some additional sizes are commented. When I want to upload a featured image to a standart or custom post i open image uploader, choose a picture and it uploads succesfully. Only if the code stays as it is above.

But if I uncomment even 1 of those other sizes and try to upload the featured image to the post - I get HTTP Error. Image's not being uploaded.

UPDATE HTTP Error goes without any error number.

Again, if I comment some of uncommented sizes and leave the new one image uploads succesfully!

After some trials I've founded that only If I leave 3 sizes uncommented in TOTAL - images upload succesfully. If I add even 1 and get 4 sizes in total - images won't upload and I get HTTP Error.

I must state that problem occurs only when working with big images with resolution bigger than 1280x800.

So, is there some kind of limit to additional image sizes? What's the problem? I use shared hosting.

ADDITION

I tried testing my WP Theme on my local xampp server and everything went well! So I can tell for sure now that problem lies in server settings. I compared my local server settings via phpinfo and my shared hosting server setting via phpinfo. I found these differences in them:

Shared server settings:

  • max_execution_time 10 10
  • max_file_uploads 128 128
  • max_input_nesting_level 64 64
  • max_input_time 60 60
  • memory_limit 64M 64M
  • post_max_size 64M 64M
  • upload_max_filesize 64M 64M

Local server settings:

  • max_execution_time 30 30
  • max_file_uploads 20 20
  • max_input_nesting_level 64 64
  • max_input_time 60 60
  • memory_limit 128M 128M
  • post_max_size 64M 64M
  • upload_max_filesize 64M 64M

Also, I tried changing memory_limit of local server from 128M to 64M and image uploads still worked well!

SOLUTION

Ok, I get the answer from my hoster and they said that error occured because of "Maximum execution time of 10 seconds exceeded in script". And suggested to add new max_execution_time value via .htaccess file in public_html folder of my website.

So I added these lines to .htaccess file in my public_html folder:

<IfModule mod_php5.c>
php_value memory_limit 128M
php_value max_execution_time 30
</IfModule>

I decided to add new memory_limit value too, just in case. Now everything works well! Thanks to everyone who tried to help me with the issue!

Was it helpful?

Solution

When using large images, it is normal at some point your server to run out of memory, so the error you are receiving is most probably related to that.

Read this post for details https://wordpress.stackexchange.com/questions/76915/http-error-when-uploading-images-over-specific-dimensions

OTHER TIPS

Could it be that you forgot to remove the semicolon at the end of this line?

add_image_size('portfolio-related-projects', 150, 150, true );

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top