get_post_meta in img src returning src

I’m developing a wordpress theme and using custom fields. I’ve got the following code:

<img alt="sunset" src="<?php echo get_post_meta($post_id->ID, 'bottom', true) ?>" height="150" width="450" border="0" />

// That code is giving this:
<img alt="sunset" src="" height="150" width="450" border="0">

I used this code to check if the custom field is empty, it returns the path to the image which is correct, the image works properly when viewed using that path.

Read More
<?php exit ( var_dump( get_post_meta($post->ID, 'bottom', true) ) ); ?>

Any ideas to why the image is not displaying correctly?

Related posts

Leave a Reply

2 comments

  1. Try this code

    <img alt="sunset" src="<?php echo get_post_meta($post->ID, 'bottom', true) ?>" height="150" width="450" border="0" />
    

    I changed $post_id->ID to $post->ID. Thanks