Get the attachment ID from media ID


#1

Hello!

I’m using get_user_meta ( $user_id, "rtmedia_featured_media", true ); to retrieve the featured media_id from a specific user.

How can I find the attachment ID from this media_id?

I need the attachment ID to retrieve width and height and order images by landscape/portrait. Is there a better way to achieve that?


#2

Hi @ricardobrg,

You can use following function to get attachment ID from media ID :

<?php $attach_id = rtmedia_media_id( $media_id ); ?>

#3