Getting the description, like and comment function in the gallery


#1

Hello.

I already read this article to customize the gallery template:

But I want to have the full like and comment functionality from media-single.php for the media-gallery-item.php, because I display larger images in the gallery and maybe don’t even need the lightbox popup then.

How can I do that? If I just copy code from the media-single.php, it won’t work for items that are loaded with “load more”.

So how to customize the code for the functions.php?

Thanks a lot.


#2

So this is what I already got for including the description:

function rtmedia_get_after_posting( $id = false ) {
	global $rtmedia;
	if( $id === false ){
		$id = rtmedia_media_id();
	}
	$output = "";
	$mediaid = rtmedia_media_id($id);
	$media = get_post($mediaid);
	$postparentID = wp_get_post_parent_id($mediaid);
    
	$output = '<p class="nomargintop">'.$media->post_content.'</p>';
	
	return $output;
}
//Filter JSON response
function rtmedia_after_posting( $media_id ) {
    global $rtmedia_backbone;
    if ( $rtmedia_backbone[ 'backbone' ] ){
    echo '<%= after_posting %>';
    } else {
    return rtmedia_get_after_posting( $media_id );
    }
}
function rtmedia_backbone_after_posting( $media_array ) {
    $media_array->after_posting = rtmedia_get_after_posting( $media_array->id );
    return $media_array;
}
add_filter( 'rtmedia_media_array_backbone', 'rtmedia_backbone_after_posting', 10, 1 ); 

How can I include the whole like and comment functionality from media-single.php into this function.


#3

Hello @joshipucher,

You want to have like feature which will make an event to like the media as well as the comment feature which will need to take user inputs for comments ( text/media ).

The code you tried can be used to display the total like count for the current media only.

Unfortunately, there is not any direct way to achieve this as it will need good customization.

Thanks


#4