This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Image in search box not showing

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Image in search box not showing

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2987
    mmousfimmousfi
    Participant

    I am having the same issues that many seems to have had but I cannot find the answer in various support messages. The image I want to show in the search box is stored in a custom field (I am using Advanced Custom Fields PRO plugin). The image only appears if it is part of a post or in a “featured image” field but not when I specify it from the custom field. So how can I get it to pick the image from the custom field called “image”.

    Thanks

    Marwan

    #2988
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    Are you sure, that the custom filed content is right? Form what I can see on your site the image urls are simple numbers, like “58” and “57”.
    It seems like the custom field value is a number instead of an image url, that’s why it isn’t working.

    #2990
    mmousfimmousfi
    Participant

    Hi, yes the returned image value is specified as a URL in the custom field.

    Thanks

    Marwan

    #2993
    mmousfimmousfi
    Participant

    Hi

    I also checked the URL in the custom field “image” for the post title Alice Mattalia and it shows http://randvital.com/wordpress/wp-content/uploads/2014/11/Alice-Mattallia.jpg

    Marwan

    #2994
    Ernest MarcinkoErnest Marcinko
    Keymaster

    I just chekced on your backend, and the custom field does not contain the url, but a number. Here you can see it: https://i.imgur.com/PyfSLgm.png

    And that’s what is visible on the frontend as well. Normally I can’t offer 3rd party plugin support, but in this case I can probably help you to get around this.

    It looks like that the number is actually the ID of the image, that has been uploaded. There is a filtering function available for the image manipulation for ajax search pro. Try to copy this code into your theme’s functions.php file:

    [php]
    add_filter( "asp_result_image_after_prostproc", "asp_cf_image", 1, 1 );

    function asp_cf_image( $image ) {
    if ($image != "" && strlen($image) < 10) {
    $atts = wp_get_attachment_image_src( $image );
    if (isset($atts[0]))
    return $atts[0];
    return null;
    }
    return $image;
    }
    [/php]

    I’m not sure if it will help, but it’s worth a try.

    #2995
    mmousfimmousfi
    Participant

    Appreciate it. I will give it a try in a moment.

    #2996
    mmousfimmousfi
    Participant

    Hi, this has resolved the problem. Thank you.

    Marwan

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.