Database query that fetches the images

I am looking to customize the plugin, when the images are fetched it’s shown according to the latest added. I want to show it ORDER BY LIKES. I am unable to find the query that fetches the images. If someone can just tell me the file name and the line of code, I will be able to do the rest. Also looking to embed that attribute in the shortcode to look something like - [rtmedia_gallery global=“true” media_type=“all” count=“4” loadmore=“true” orderby=“likes/date/comments”] etc.

I found the custom code answer. In RTMediaModel.php on line 170 the code is

function get_media ( $columns, $offset = false, $per_page = false, $order_by = 'media_id desc', $count_flag = false ) {  
        if ( is_multisite () ) {  
        $order_by = "blog_id" . (($order_by)? "," . $order_by :'');  
    }

replace the media_id with likes to order by likes or any other attribute from the db to sort by.

Now second step is integrating with the shortcode. That I am still looking into.

Hi Neeraj,
This way you need to make changes in plugins itself which will be vanished in future if you update the plugin.
Another solution is to use available filter in your theme only. Check this similar support thread -> https://rtcamp.com/support/topic/photos-in-gallery-view-order/ for more information.

Thanks for the reply. I knew it but didn’t think of it. Glad with your response. I will be using your way for now.
Also, can you like add functions in the next release of the plugin along with shortcode like I had mentioned in the first question, so that other users can use it.

Hi Neeraj,

I will discuss this with my team. I am putting this support topic under “Feature Request” category for future reference.

Yes, sure. Now what I did to overcome with updates is. I created a new add-on like plugin with the filter to ORDER BY LIKES and ORDER BY COMMENTS so even if the theme or plugin is updated or the theme is changed the user won’t have issues with it.
And thanks for the replies and support.

That’s great, you are awesome :slight_smile: