Jump to content

Getting image from search page


Recommended Posts

I am trying to get an image to go along with my search results. I can create the image as a file but of course the path is incorrect as it refers to the  search page itself. Any idea how I can reference the relevant assets file folder?

foreach($matches as $m) {
    $img = $m->images->last->width(200);
    $out .= "
	    <img src='{$img}' />
	    <h4><a href='{$m->url}'>{$m->title}</a></h4>

Thanks again

Link to comment
Share on other sites

To start with, last should be last() (I think)

So $img = $m->images->last()->width(200);
Then you need to get the url for the image
<img src='{$img->url}' />
The URL contains all the path data.
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...