Support » Plugin: Meta Box - WordPress Custom Fields Framework » Retrieving image url from custom post type

  • I’m having a bit of bother with retrieving an image url from an image added to a custom post type, retailers, with plupload.

    The standard code

    $images = rwmb_meta( 'flb_meta_plupload', 'size=medium' );
    if ( !empty( $images ) ) {
        foreach ( $images as $image ) {
            echo "<img src='{$image['url']}' />";

    Works when displaying an image on it’s own page (eg, retailers/amazon will only show the Amazon logo), but I want to show a list of retailer logos in my footer.

    I’m trying to create a widget that will show all logos with the following code:

    // Pull through Retailers
    $flbretailers = get_posts(array(
           'post_type' => 'flb_retailers',
           'orderby' => 'title',
           'order' => 'asc',
    // Display for each Retailer
    foreach ($flbretailers as $flbretailer) {
           $custom = get_post_custom($flbretailer->ID);
           $meta_ret_img = get_post_custom($flbretailer->flb_meta_plupload);
           $meta_ret_url = $custom["flb_meta_url"][0];
           // Display Retailers
           echo "<li><a href='{$meta_ret_url}'><img src='{$meta_ret_img}' /></a></li>";

    The problem here seems to be the line

    $meta_ret_img = get_post_custom($flbretailer->flb_meta_plupload);

    Which returns “Array”, but I don’t know enough php to have it return the image URL from the array values. I have also tried

    $meta_ret_img = $custom["flb_meta_plupload"][0];

    In place of the above line but that seems to return the image ID. Any ideas?

    NB, the line

    $meta_ret_url = $custom["flb_meta_url"][0];

    Is for a separate URL field entered by the user. This works fine.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Retrieving image url from custom post type’ is closed to new replies.