Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Image source settings
- This topic has 4 replies, 2 voices, and was last updated 7 years ago by
Ernest Marcinko.
-
AuthorPosts
-
May 24, 2019 at 2:31 pm #22852
DSLMS
ParticipantHello, 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?
May 24, 2019 at 2:33 pm #22855DSLMS
ParticipantYou cannot access this content.
May 27, 2019 at 9:04 am #22864Ernest Marcinko
KeymasterHi!
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:
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; }May 29, 2019 at 10:53 am #22933DSLMS
ParticipantYou cannot access this content.
May 29, 2019 at 12:10 pm #22934Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- You must be logged in to reply to this topic.