简体   繁体   中英

Upload suddenly failing from WP Bakery Single Image Block

I am having an issue regarding uploading an image from WP Bakery's Single Image Block Upload.

  • When I upload from the library, Wordpress selects properly the image and the image in the Bakery's Visual editing is properly updated.
  • When I load a new image from my computer ( Select a file and upload ) I get an " Error loading. Please try again " message.

Steps taken to track this issue

Upon inspection of the request made to WP's wp-admin/async_upload.php , on Chrome, I get this response:

{"success":false,"data":{"message":"","filename":"food-2373414_1920.jpg"}}

I attempted to track the issue in wp-admin/ajax-actions.php , and the error first occurs around line 2561 which has the following snippet:

$attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data );    

if ( is_wp_error( $attachment_id ) ) {
    echo wp_json_encode(
        array(
            'success' => false,
            'data'    => array(
                'message'  => $attachment_id->get_error_message(),
                'filename' => esc_html( $_FILES['async-upload']['name'] ),
            ),
        )
    );

    wp_die();
}

Note: I say first occurs because the request dies and can't follow up in the next lines. So, at this time, the block above is the first obstacle.

Dumping $attachment_id

WP_Error::__set_state(array(
   'errors' => 
  array (
    'upload_error' => 
    array (
      0 => '',
    ),
  ),
   'error_data' => 
  array (
  ),
))

Configurations and Environment

PHP 7.2 w/ Mod Security disabled from Cpanel, w/ GD & Imagick

Server Apache

0777 Permissions at uploads folder

Wordpress Settings:

WP Version: 5.4.1

URL and Site URL's both start with https://

User is Administrator

Theme: Business Consulting

Other information researched and findings:

  • On a test server, the upload works as expected. From the environment and wordpress settings everything, except for ModSec ( which in the test server does not exist in the Cpanel ). I have also found out that by disabling a plugin ( Real Simple SSL and SSL Insecure Fixer ) and logout and login again, the issue seemed to take care of itself, but I have tried the same in the production server and doesn't work.

  • Mostly errors from this nature only relate to a HTTP Error occuring. Even trying to use the fixes stated in some sites ( permissions, changing Imagick to GD as the image processing library, giving more memory, max_upload_file_size, max_execution_time, max_input_vars, does not seem to fix this issue.

  • Opening the website in a Private Tab does not work, as well as opening in Firefox.

Other possible causes:

I edit Wordpress content in https://.

Every listing's pages, does not show the Mixed Content warnings, but when I edit a give article from the theme, there a lot's of MC warnings. That does not seem to hinder the upload, but for now I will leave them as it is. The request to async_upload is made via SSL, so I don't think the MC's are the cause. But for Murphy's Law sake, I will replace the http:// to https:// and try again.

Thank you in advance for your help.

I was able to figure it out.

The problem is that, when I changed the slugs from on of the Advice theme's sections ( adv_cases to adv_portfolio ), the upload from articles that were previously registered before this changed were not working.

I solved it by duplicating or creating a new post, and voilá, the upload works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM