Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Image in search box not showing
This topic contains 6 replies, has 2 voices, and was last updated by mmousfi 9 years, 9 months ago.
- AuthorPosts
- November 20, 2014 at 10:16 am #2987
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
November 20, 2014 at 10:20 am #2988Hi!
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”.
Best,
It seems like the custom field value is a number instead of an image url, that’s why it isn’t working.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 20, 2014 at 10:29 am #2990Hi, yes the returned image value is specified as a URL in the custom field.
Thanks
Marwan
November 20, 2014 at 10:32 am #2993Hi
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
November 20, 2014 at 10:48 am #2994I 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:
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; }
I’m not sure if it will help, but it’s worth a try.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 20, 2014 at 10:54 am #2995Appreciate it. I will give it a try in a moment.
November 20, 2014 at 10:55 am #2996Hi, this has resolved the problem. Thank you.
Marwan
- AuthorPosts
You must be logged in to reply to this topic.