Skip to content
Advertisement

Get post_meta image url based on ID

So i’d like to extract the image url from the database on one of my post_meta, but I’m unsure how to target that.

Here is the steps that I’m taking:

Here is what’s under the wp_postmeta table in the database:
enter image description here

If I navigate to wp_posts – I get the meta_value post with my url inside as such:
enter image description here


When I do $test = get_post_meta($post->ID, 'full_image'); I get the following:
enter image description here

How does one extract the image url from wp_posts based on $post->ID? I’m having the hardest time targeting it.


UPDATE:

If I do var_dump(get_attached_media('image', $post->ID)); – I get the following results:
enter image description here

How do I grab the guid url?

Advertisement

Answer

Got it working using this method:

$this->set_full_image(wp_get_attachment_image_url( get_post_meta($post->ID, 'full_image', true), 'large'));

The reason that I wasn’t getting any results back is because get_post_meta was returning an array and not a single value so I had to set true at the end.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement