I can't get images to show for buddypress search results page

Home Forums Product Support Forums Ajax Search Pro for WordPress Support I can't get images to show for buddypress search results page

This topic contains 10 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 4 years, 10 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #23190
    dando
    dando
    Participant

    Hi, I’ve got this problem on my site where when you search for buddypress users, on the results page there are no avatars, just names, in one solid column. I can solve the layout problem with elementor, but try as I can I can’t get the avatars to show up. images show up for any other post type

    #23191
    dando
    dando
    Participant

    This is how it looks

    #23197
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Thank you for all the details. Unfortunately the plugin cannot affect the results page layout, it is fully controlled by the theme you are using. Usually themes support only post types with images, so profile images may not show there. It might be possible to get the images via a modification though. There is a theme function api available, but you will have to ask the theme author as well on how exactly modify the images within the theme files via a child theme.

    In your case, you are looking to implement something like this, to pass the search images to the results page:

    <?php
    $asp_img = get_asp_result_field('image');
    if ( !empty($asp_img) ) {
      echo "<img src='$asp_img'>";
    } ?>
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #23200
    dando
    dando
    Participant

    Is this for groups only? I’m using Jupiter X, and I’ve added your code to the search.php fragment like this;

    function jupiterx_post_image() {
    	$asp_img = get_asp_result_field('image');
    	if ( !empty($asp_img) ) {
    	  echo "<img src='$asp_img' />";
    	}

    after this, if I search for a term that affects both groups and users, the search reveals the groups images, but not the users.

    You can see the result here;

    search results

    • This reply was modified 4 years, 10 months ago by dando dando.
    • This reply was modified 4 years, 10 months ago by dando dando.
    #23204
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    No, it should work with anytthing there. Mabye something is overriding those images, I am not sure.

    Try maybe a bit more advanced modification:

      $asp_type = get_asp_result_field('content_type');
      $asp_img = get_asp_result_field('image');
      $asp_id = get_asp_result_field('id');
      if ( !empty($asp_img) ) {
        echo "<img src='$asp_img' />";
      } else if ( $asp_type == 'user' ) {
        if ( function_exists('bp_core_fetch_avatar') ) {
            $im = bp_core_fetch_avatar(array('item_id' => $asp_id, 'html' => false));
        } else {
            $im = $this->get_avatar_url($asp_id);
        } 
        if ( !empty($im) ) {
          echo "<img src='$im' />";
        }
      }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #23205
    dando
    dando
    Participant

    That did the trick 🙂 thank you so much Ernest, you’re a life saver

    #23206
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #23207
    dando
    dando
    Participant

    just one last thing – if I click on a user’s name, the link takes me to /author/admin/ instead of members/admin. is this a theme thing as well?

    • This reply was modified 4 years, 10 months ago by dando dando.
    #23209
    dando
    dando
    Participant

    don’t stress, I found the solution –

    I’m putting it here in case anyone else has this problem, go to your functions.php and add this;

    add_action(‘init’, ‘cng_author_base’);
    function cng_author_base() {
    global $wp_rewrite;
    $author_slug = ‘members’; // change slug name
    $wp_rewrite->author_base = $author_slug;
    }

    This will modify the slug for authors

    #23210
    dando
    dando
    Participant

    can the_asp_result_field return a link to the profile?

    #23216
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Not sure about that, it may not work, but if so, then it should return the same link as set here.

    <a href="<?php echo get_asp_result_field('link'); ?>">My link</a>

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.