Custom Fields
Support General Single image troubles

  • Creator
  • #21226

    Troubles with single image. In the documentation:
    The documentation: I can use the helper function rwmb_meta() and this return an array of image information. However I am trying but the helper function only return an string with the ID of attachment.

    array (
    'id' => $prefix . 'if_vehiculos_imagen2',
    'type' => 'single_image',
    'name' => esc_html__( 'Imagen principal', 'text-domain' ),
    'tab' => 'if_vehiculos_tab_general',

    In my functions.php

    $query = new WP_Query(array(
    'post_type' => 'vehiculo',
    'post_status' => 'publish',
    'posts_per_page' => -1,
    while ($query->have_posts()) {
    $imagen = rwmb_meta('if_vehiculos_imagen2', array( 'size' => 'miniatura' ),$post_id );

    Full PHP code

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
  • #21231
    Long Nguyen


    Please see my screen record

    When you get the field single_image value by the helper function rwmb_meta(), it returns an array of the image as well.

    You can check again with this code

    $imagen = rwmb_meta( 'if_vehiculos_imagen2', array( 'size' => 'thumbnail' ), $query->post->ID );


    Sorry but it don't work for me. The helper is returning a string with the ID of attschment.

    Long Nguyen


    Here is my sample code to get the single_image field's information via custom query

    $query = new WP_Query(array(
        'post_type' => 'post',
        'post_status' => 'publish',
        'posts_per_page' => 10,
    while ($query->have_posts()) {
        $image = rwmb_meta( 'post_meta_single_image', array( 'size' => 'thumbnail' ) );
        echo '<a href="', $image['full_url'], '"><img src="', $image['url'], '"></a><br>';
        echo "<pre>";
        echo "</pre>";

    and a screen record demonstrates

    Could you please take some screenshots of a screen record of this issue? I will take a closer look and give a quick response.

    Long Nguyen

    Use your code to reproduce the issue, but it still works as well


    Hello, I really appreciate your time. Very good support. It still doesn't work for me. I don't know if it's because I'm using this code in my functions.php

    but I have to do the following:

    $imagen = rwmb_meta('if_vehiculos_imagen', array( 'size' => 'full' ));
    $full = (wp_get_attachment_image_src($imagen,'full'));

    I checked that metabox definition was before this code. Some idea for solved it?

    Long Nguyen


    Please make sure that you are using Meta Box v5.3.3, deactivate all plugins except Meta Box and MB extensions, switch to the default theme of WordPress (Twenty Twenty) then check the issue again.

    If it still shows only image ID, please follow this guide to know how to create the staging site

    Then share the credentials (Admin site and FTP account) via this form I will check it out.


    I'm having the same problem, except it's with Image Advanced, with multiple images saved to the post. Not only does it only return an ID instead of an array of stuff, it only returns ONE ID, even if there's more than one pic saved to that post.

    I've turned off all non-MB plugins, switched the theme to Twenty Twenty, and it's still happening.

    I confirmed in the database that all three images exist for that post in wp_post_meta.
    Since I turned off my plugin that defined the CPT that has the Image Advanced, the way I declared the field doesn't matter (it wasn't in a group, though).

    Here is what I put in a template file - putting in the post ID of the CPT post that has the images, since that CPT doesn't exist right now, but it still returns a single integer, matching one of the 'meta_value' fields of the images I put on the post.

    var_dump(rwmb_meta('product_gallery', array('size' => 'full'), '345'));
    This gives me
    string(3) "525"
    output on the page.

    Thank you for any help you can provide!

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