• Resolved mxpimp47

    (@mxpimp47)


    I read the documentation example on retrieving a medium image for the “file” meta box. But I cannot get it to display an image. I did not rename the “id” it is test_image. I have an image uploaded in my custom options page. This is my code –

    $image = wp_get_attachment_image( get_post_meta( get_the_ID(), 'test_image_id', 1 ), 'medium' );

    I wrapped that inside php tags, and that is inside img src html tags. What am I missing?

    edit- I added echo $image; in the line above

    https://wordpress.org/plugins/cmb2/

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter mxpimp47

    (@mxpimp47)

    I dont know why I was thinking I needed a loop to display this. But I revised my code to this (with the third argument you mentioned) – http://pastebin.com/HHJcaUuH for anyone following along here. I needed to display 1 image and thats all I was saving via the custom meta (via the admin). When I reset the image field to nothing and save it, or upload a different image, it updates the DB.

    Essentially that setup will return the same page every time.

    I did want to return what ever image was stored in that meta field, cause it will only ever be one image since its used on the admin side, not page or posts. It is intended to be updated directly.
    Does that clear any confusion up on that part?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I was never confused by it 🙂 Just wanted to point out what I had noticed.

    Anyways, it sounds like you’re in a good position now, and things are cleared up.

    Are we good to mark resolved?

    Thread Starter mxpimp47

    (@mxpimp47)

    Yes, we can mark it resolved. I appreciate the help! I was just trying to fully understand what you meant, I was confused. Were you just simply stating that it will do what I wanted?

    Thank you again for the help!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I wasn’t sure if that’s what you wanted or not, so I pointed out the behavior that’d occur. But it is, so that’s good.

Viewing 4 replies - 16 through 19 (of 19 total)

The topic ‘echo the "file" meta box problem’ is closed to new replies.