Support » Plugin: MediaPress » Default thumbnail

  • Resolved evasophi


    Hi there,

    I want to change the default thumbnail for gallery, based on user conditions.

    The code is written in “plugins/mediapress/core/gallery/mpp-gallery-cover-templates.php”. but, changing the core code is not good.

    The function which I want to change is “function mpp_get_default_gallery_cover_image_src( $gallery, $cover_type )” like this as given below.

    function mpp_get_default_gallery_cover_image_src( $gallery, $cover_type ) {

    $gallery = mpp_get_gallery( $gallery );

    $type = bp_get_member_type( bp_logged_in_user_id );

    if ( $type == ‘doctor’ )
    {$cover_type = “……./doctor.png”;
    elseif ( $type == ‘nurse’ )
    {$cover_type = “……./nurse.png”;
    {$cover_type = “……./patients.png”;
    return $covertype;

    Can anyone suggest, How can I redefine this function.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author BuddyDev


    Thank you for using MediaPress. It’s very easy to accomplish without modifying core.

    We can use the filter “mpp_get_gallery_default_cover_image_src”

    I have a question before I can assist you further. Do you want it based on logged in user id or do you want it to be based on gallery’s owner id?

    Thank you

    Thank you for your quick response.

    I want it based on gallery’s owner id

    Plugin Author BuddyDev


    Thank you. You may use the following code

     * Custom default MediaPress gallery cover based on member type.
     * @param string      $cover_src cover image url.
     * @param string      $type gallery type(photo, audio, video, doc etc)
     * @param MPP_Gallery $gallery Gallery object.
     * @return string
    function mpp_custom_gallery_cover( $cover_src, $type, $gallery ) {
    	$gallery  = mpp_get_gallery( $gallery );
    	$owner_id = $gallery->user_id; // user_id will work in cases(groups, user's sitewide).
    	$member_type = bp_get_member_type( $owner_id, true );
    	switch ( $member_type ) {
    		case 'doctor':
    			$cover_src = "";
    		case 'nurse':
    			$cover_src = "";
    			// this is the fallback cover if you want to modify it too.
    			$cover_src = "";
    	return $cover_src;
    add_filter( 'mpp_get_gallery_default_cover_image_src', 'mpp_custom_gallery_cover', 10, 3 );

    Please do modify the values as you need.


    Thank a lot. Perfectly fine.

    Although curious to know about difference between

    $owner_id = $gallery->user_id;

    $owner_id = mpp_get_gallery_creator_id($gallery)

    Thanks a lot

    Plugin Author BuddyDev


    You are welcome. There is no difference between these two. mpp_get_gallery_creator_id is a wrapper function and will be a better choice for future compatibility.


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Default thumbnail’ is closed to new replies.