Custom Fields
Support General Bug image advanced with woocommerce featured image

  • Creator
  • #27903
    Resolved Felipe Pereira

    Hi guys, how are you?
    I need help with a bug I found.
    I created some image galleries with advanced image on the woocommerce product pages. However, I found that if I add an image to these galleries, I will no longer be able to change the highlighted image of the product.
    I have already rewritten the code, I have redid the advanced images and the bug continues, it is only possible to change the product images if there is no photo in the gallery created with advanced images from the metabox.

    I hope you can help me.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Author
  • #27905
    Long Nguyen

    Hi Felipe,

    That was not a bug. The field type image_advanced has the setting 'multiple' => true which means the value is saved in the database as a serialized array, not only one attachment ID as featured image. You can use the field type single_image instead of and refer to this topic to replace the default featured image box with a custom field.

    Felipe Pereira

    Hi Long Nguyen.
    Thanks for your feedback, but I'm not really trying to replace the product's featured image on woocommerce. I added a gallery with multiple images with the metabox, they are complementary images to the product, and when adding an image to this gallery there is an error that I can no longer change the featured image of the product (official of woocommerce). It is only possible to change the product image when I remove 100% of the images from the gallery created with the metabox.

    Long Nguyen

    Hi Filipe,

    Can you please share the code that creates meta box and custom fields for the post-type Product? I will check it on my end.

    Felipe Pereira

    Hi, Long Nguyen, of course I can.
    It is a long code because we have several fields, from attachments to fields with texts and complementary information.


    Long Nguyen

    Hi Filipe,

    Use your code to create custom fields on the product editing page, I do not see any issue. Screen record

    Please follow the Debugging Information step here to troubleshoot this issue. Let me know how it goes.

    Felipe Pereira

    Hi Long Nguyen,

    After saving or updating the product, did you try to remove or change the featured image of the product?

    First test with a product with several images added in the galleries created with metabox:

    Second test removing advanced image images created with metabox:

    The problem occurs after we save the product with the images added to the gallery created by the metabox.

    Long Nguyen


    Yes, it still works when I remove/change the featured image of the product. Screen record

    It is possible that there is a conflict between plugins. You can try to follow the Debugging Information on the reply above to troubleshoot this issue.

    Felipe Pereira


    I discovered the conflict, I was using ACF to create personalized fields for users, photographers and products in the attachments and that was what was causing conflict.

    Thanks for your help was lost before, for anyone who has the same problem follows solution used with metabox to replace the ACF plugins.

    add_filter( 'rwmb_meta_boxes', 'metabox_attachment_photographer_register_meta_boxes' );
    function metabox_attachment_photographer_register_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = [
            'title'   => esc_html__( 'Fotográfo', 'decostore' ),
            'id'      => 'attachment_photographer',
            'context' => 'normal',
            'post_types' => 'attachment',
            'media_modal' => true,
            'fields'  => [
                    'type'       => 'user',
                    'name'       => esc_html__( 'Fotográfo', 'decostore' ),
                    'id' => 'attachment_photographer',
                    'field_type' => 'select',
                    'query_args' => [
                        'role' => 'photographer',
                        'order'   => 'ASC',
                        'orderby' => 'title',
        return $meta_boxes;
    Long Nguyen

    Let me know if you have any questions 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.