Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter ghaiath

    (@ghaiath)

    Sure, I sent a message their but could not send the Theme Houzez to you.

    I checked that when I upload an image, this houzez_property_img_upload is called, maybe this help:

    add_action( 'wp_ajax_houzez_property_img_upload', 'houzez_property_img_upload' );    // only for logged in user
    add_action( 'wp_ajax_nopriv_houzez_property_img_upload', 'houzez_property_img_upload' );
    if( !function_exists( 'houzez_property_img_upload' ) ) {
    function houzez_property_img_upload( ) {

    // Check security Nonce
    $verify_nonce = $_REQUEST['verify_nonce'];
    if ( ! wp_verify_nonce( $verify_nonce, 'verify_gallery_nonce' ) ) {
    echo json_encode( array( 'success' => false , 'reason' => 'Invalid nonce!' ) );
    die;
    }

    $submitted_file = $_FILES['property_upload_file'];
    $uploaded_image = wp_handle_upload( $submitted_file, array( 'test_form' => false ) );

    if ( isset( $uploaded_image['file'] ) ) {
    $file_name = basename( $submitted_file['name'] );
    $file_type = wp_check_filetype( $uploaded_image['file'] );

    // Prepare an array of post data for the attachment.
    $attachment_details = array(
    'guid' => $uploaded_image['url'],
    'post_mime_type' => $file_type['type'],
    'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $file_name ) ),
    'post_content' => '',
    'post_status' => 'inherit'
    );

    $attach_id = wp_insert_attachment( $attachment_details, $uploaded_image['file'] );
    $attach_data = wp_generate_attachment_metadata( $attach_id, $uploaded_image['file'] );
    wp_update_attachment_metadata( $attach_id, $attach_data );

    $user_id = get_current_user_id();
    $watermark_image_url = get_user_meta($user_id, 'fave_watermark_image', true);

    $thumbnail_url = wp_get_attachment_image_src( $attach_id, 'houzez-item-image-6' );

    $feat_image_url = wp_get_attachment_url( $attach_id );

    $ajax_response = array(
    'success' => true,
    'url' => $thumbnail_url[0],
    'attachment_id' => $attach_id,
    'full_image' => $feat_image_url
    );

    echo json_encode( $ajax_response );
    die;

    } else {
    $ajax_response = array( 'success' => false, 'reason' => 'Image upload failed!' );
    echo json_encode( $ajax_response );
    die;
    }

    }
    }
    Thread Starter ghaiath

    (@ghaiath)

    Thanks Anton,

    I downloaded the latest version 1.9.6-beta. And uploaded it. Then tried to add an image using the frontend and does not seems to get offloaded. Retried with an admin and it worked.

    Do I need to deactivate and activate the plugin before I test?

    Thread Starter ghaiath

    (@ghaiath)

    Ok, thanks a lot Anton.

    Thread Starter ghaiath

    (@ghaiath)

    Hi Anton,
    I just enabled Debug logs and I got this log. Can’t analyse that, but seems that it require an instance of Admin class or something that init does not return?

    Fatal error: Uncaught TypeError: CF_Images\App\Core::admin(): Return value must be of type CF_Images\App\Admin, null returned in wp-content/plugins/cf-images/app/class-core.php:342 Stack trace: #0 wp-content/plugins/cf-images/app/traits/trait-helpers.php(112): CF_Images\App\Core->admin() #1 wp-content/plugins/cf-images/app/modules/class-auto-offload.php(53): CF_Images\App\Modules\Auto_Offload->media() #2 wp-includes/class-wp-hook.php(324): CF_Images\App\Modules\Auto_Offload->auto_offload() #3 wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #4 wp-includes/plugin.php(517): WP_Hook->do_action() #5 wp-settings.php(727): do_action() #6 wp-config.php(120): require_once('/home/u22298071...') #7 wp-load.php(50): require_once('/home/u22298071...') #8 wp-blog-header.php(13): require_once('/home/u22298071...') #9 index.php(17): require('/home/u22298071...') #10 {main} thrown in wp-content/plugins/cf-images/app/class-core.php on line 342
    Thread Starter ghaiath

    (@ghaiath)

    Thanks Anton, I changed it myself, I didn’t copied it from WordPress support here. But still the same issue. Should I turn on the debug and se what it the error?
    I tried to add a screenshot here, not sure if you can see it. But, I just replaced admin_init with init. And the colors seems to be correct.

    Thread Starter ghaiath

    (@ghaiath)

    Many thanks Anton,

    Tried to do as you told me. Once I change to “init”, the whole site crashes. Probably because the Offload Media to Cloudflare Images plugin crashes?

    Thread Starter ghaiath

    (@ghaiath)

    Thanks Anton, I guess you are referring to this commit?
    https://github.com/av3nger/cf-images/commit/ad5bbfb5a5250bf9ebb7a67d087bc22039803c03

    I did that change and even added both manage_options and upload_files permissions to the role I use to upload images. But still the images didn’t get offloaded automatically.

    The difference here that I’m using Houzez theme and the users can upload the images using Frontend. And the images ends up in the media. But the images doesn’t get offloaded automatically.

    Houzez have custom roles, like agency, I have added both upload_files and manage_options permissions to that role, but still no automatic offload.

    Best regards

    Thread Starter ghaiath

    (@ghaiath)

    Thanks again Anton,

    My bad, I didn’t explain the issue correctly. πŸ˜…

    I can upload both WebP and AVIF just fine. But I get this error only when I turn on the option β€œDisable WordPress image sizesβ€œ.

    * β€œDisable WordPress image sizesβ€œ off –> I can upload webP and AVIF.
    * β€œDisable WordPress image sizesβ€œ on –> I get the error: β€œThe web server cannot generate responsive image sizes for this image. Convert it to JPEG or PNG before uploading.”

    I also checked the extensions installed. I’m using Hostinger and I can see that thy support and enabled WebP and AVIF.
    “GD supported file formatsGIF, JPEG, PNG, WebP, BMP, AVIF, XPM”
    Even ImageMagick supported file formats: “… AVIF, WebP”.

    Thanks in advance.

    Thread Starter ghaiath

    (@ghaiath)

    Thanks Anton,

    Today, I tried the option “Disable WordPress image sizes“. It seems to be working fine with only jpg or png. When I tried to upload webp images, then I got:


    “The web server cannot generate responsive image sizes for this image. Convert it to JPEG or PNG before uploading.”

    Is there any extra steps I have to do?

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)