• Resolved exion98

    (@exion98)


    Hello,
    I’m using this plugin and it is great. I just found an issue with 2 things actually that I don’t know how to figure out so i’m asking here. These regarding Images and description field in the dropdown result box:

    1)Images: I have 2 kind of posts, one with a featured image 600×900 and the other one 1920×1080. In other terms, one is 2:3 and the other one is 16:9. I can’t find a way to set both images to be shown properly. I thought that setting the correct size for the 16:9 ratio would fix both images, with the 2:3 images that would shown up entirely in hight and with some white space on the left and the right to compensate the width, but actually the plug in re-size the images ruining the visual. Here 2 example, 1 with the size set up for the 16:9 ratio, one with the 2:3 ratio.

    View post on imgur.com

    View post on imgur.com


    How can I show both images with their personal ratio?

    2)Description: I want set a description next to the image that look like this: https://imgur.com/IUElMZy ,one line under other one, but the plugin does not consider the space so here how it looks in the result box: https://imgur.com/AbKxu3A
    How can I fix that?

    Thanks for any help.

    • This topic was modified 4 years ago by exion98.
    • This topic was modified 4 years ago by exion98.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi,

    1. Try this custom CSS:

    div.asl_r .results .item .asl_image {
        background-size: contain !important;
    }

    This should force the images to resize to the closest size to fit into the background cover space.

    2. Well, the HTML tags are stripped automatically from the content section, so I am not sure if that is possible to do so without custom coding. You could try a hook to parse the post contents after the search is finished, like so:

    add_filter( 'asl_results', 'asl_get_the_content_after', 10, 1 );
    function asl_get_the_content_after( $results ) {
    	
    	// Parse through each result item
    	foreach ($results as $k=>&$r) {
    		if ( isset($r->post_type) ) {
    			$r->content = apply_filters('the_content', get_post_field('post_content', $r->id));
    		}
    	}
    
    	return $results;
    }

    Best,
    Ernest M.

    Thread Starter exion98

    (@exion98)

    1)This code actually do something and it is close to the solution. Here what happened with this code (I wrote it in Ajax Search Lite>Layout options>Custom CSS):

    View post on imgur.com

    View post on imgur.com

    2)I wrote this code like above in layout options>custom CSS, but nothing happens and nothing change, maybe i must wrote it in another field?

    Plugin Author wpdreams

    (@wpdreams)

    Hi,

    1. Try this variation without background repeat:

    div.asl_r .results .item .asl_image {
        background-size: contain !important;
        background-repeat: no-repeat !important;
    }

    2. Sorry, I forgot to specify. Use that in the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case.

    Best,
    Ernest M.

    Thread Starter exion98

    (@exion98)

    The first problem has been resolved, so thank you SO MUCH for your fast and easy solution.

    The second one, unfortually, is still present. Whit that code the result box give back the title of the post(like above) but in the description field it put everything the post have inside, whether texts or images. Also it doesn’t pick the description anymore and the result box take for itself the full page height, without a scroll tab inside. Here an example:

    View post on imgur.com

    View post on imgur.com

    Plugin Author wpdreams

    (@wpdreams)

    You are very welcome. I understand, I thought you wanted the whole post description within the search results – looks like that is within the post content field.
    You could try a different variation to maybe get the excerpt (if that is what you need)?
    However excerpts usually don’t have HTML tags or line breaks, so it may not look different from the initial result:

    add_filter( 'asl_results', 'asl_get_the_content_after', 10, 1 );
    function asl_get_the_content_after( $results ) {
    	
    	// Parse through each result item
    	foreach ($results as $k=>&$r) {
    		if ( isset($r->post_type) ) {
    			$r->content = get_post_field('post_excerpt', $r->id);
    		}
    	}
    
    	return $results;
    }

    Best,
    Ernest M.

    Thread Starter exion98

    (@exion98)

    Yeah my intention was to show in the dropdown results box the excerpt of the post with just a few thing that I wrote in the field. But you are right, this code get the excerpt but not the space that i want it. Do you have any suggestion to show in every result a my personal description in that style(1 line below the other)? Not necessary using the excerpt field, just a method that give me the possibility to have a unique field in that results box that doesn’t appear in the post itself. If you haven’t it don’t worry, you’ve already done a lot, I thanks you again.

    Plugin Author wpdreams

    (@wpdreams)

    Well, maybe using a custom field could actually work. I would probably a custom field, or maybe even more of them – each for every data you want to show. Then modify the code above to print all of those data as needed. Especially if you have like the same structure for every post.

    Best,
    Ernest M.

    Thread Starter exion98

    (@exion98)

    Thanks, i will try it.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Result Box images and description’ is closed to new replies.