How to get url path to uploaded image file?

Hello,

Is there a way to get the url path to an image media file?

I know about get_rtmedia_permalink(rtm_media_id) function but that returns something like: wordpress/members/username/media/5/ which is the webpage that displays the image rather than the image itself.

I want something like: wordpress/wp-content/uploads/rtMedia/users/1/2015/04/imageName.png

Thanks.

Hi @disastorm

rtMedia uses wp_get_attachment_image_src WordPress function to get image source. You can use same function to get image source path.

wp_get_attachment_image_src( $rtm_media_id, $size );

You can either use rt_media_thumbnail or rt_media_activity_image or rt_media_single_image as a size parameter. Those are the media image size for rtMedia imags.

Thanks, thats good to know.

I actually ended up using rtmedia_image($size, $rtm_media_id) although it was a little strange since just calling this function prints out the url as opposed to returning it, but it worked for what I wanted to do.

Hello @disastorm,

Yes, you can also use that function which in turn calls wp_get_attachment_image_src() function to get the image src. rtmedia_image is generic function to get album image/music cover and image source.

If you want to return the path, you will need to pass false in 3rd argument of the function.

For example: $img_path = rtmedia_image( $size = ‘rt_media_thumbnail’, $id = 1, $recho = false );

Thank you.