How do I get the image from a post

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

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


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

				<li>
					<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>
					</a>
					<div class="sidecontent">				
						<a href="<?php echo $item->url() ?>" title="<?php echo $item->title()->html() ?>">
						<span><?php echo $item->title()->html() ?></span>		
						</a> 
					</div>
				</li>
				<?php endforeach ?>
			</ul>
		</aside><!-- .right-sidebar --><!--sidebar-->
1 Like

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

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

With

<?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: