How do I get the image from a post

This my code for a sidebar, all is working. Just my image not.

$items = $pages->filterBy('tags', 'cars', ',');

		<aside class="right-sidebar">
				<div class="sidebarheader">
				<h1>Die besten Eiweißpulver</h1>
					<div class="articleboxside">
				<?php foreach($items as $item): ?>

					<a href="<?php echo $item->url() ?>">
						<div class="siderating">92%</div>	
						<div class="sideimage">			
							<img src="<?php echo $item->images()->first();?>" class="sidethumb" alt="<?php echo $item->title()->html() ?>">	
					<div class="sidecontent">				
						<a href="<?php echo $item->url() ?>" title="<?php echo $item->title()->html() ?>">
						<span><?php echo $item->title()->html() ?></span>		
				<?php endforeach ?>
		</aside><!-- .right-sidebar --><!--sidebar-->
1 Like

Try calling the url() method on the image object:

<img src="<?= $item->images()->first()->url() ?>" alt="" />
1 Like


<?php echo $item->images()->first() ?>

you will get the image object. Try using

<?php echo $item->images()->first()->url() ?>

to get the image URL

1 Like

Aaaah so close!
Thank you both :slight_smile: