Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Image source settings
This topic contains 4 replies, has 2 voices, and was last updated by Ernest Marcinko 4 years ago.
- AuthorPosts
- May 24, 2019 at 2:31 pm #22852
Hello, I have an issue with the result image settings.
In Alternative image source 3 I have a custom field selected. This works fine with my custom image.
In Alternative image source 4I have the default image selected.The problem is that when source 4 is set, it gets priority over source 3 somehow and shows instead!
If I disable source 4 then it shows the custom image correctly. When I turn source 4 back on the result then shows from source 4 instead of source 3.I’ve attached screenshots in two zip files that i’ve attached show what I mean if I haven’t explained it well.
Any ideas why this is happening please?
Attachments:
You must be logged in to view attached files.May 24, 2019 at 2:33 pm #22855You cannot access this content.May 27, 2019 at 9:04 am #22864Hi!
The issue is related to a custom code you have to get the taxonomy images within your theme functions.php file. Since the plugin does not find the image internally, it uses the default image. Then the custom code is executed, but since there is already an image, it is not in use. Try replacing it with this variation instead:
Best,add_filter( "asp_results", "asp_acf_cf_image", 10, 1 ); function asp_acf_cf_image( $results ) { // Change this to the ACF custom field name $image_field = 'search_image'; $default = 'https://domain.com/wp-content/plugins/ajax-search-pro/img/default.jpg'; // ---------------------------------------------- // --- Do not change anything below this line --- // ---------------------------------------------- foreach ( $results as $k => &$r ) { if ( ( empty($r->image) || $r->image == $default ) && $r->content_type == 'term' ) { $img = get_field($image_field, $r->taxonomy . '_'.$r->id); if ( !empty($img) ) $r->image = str_replace("'", "%27", $img); } } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 29, 2019 at 10:53 am #22933You cannot access this content.May 29, 2019 at 12:10 pm #22934You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.