Get Search Result Image URL

I am trying to get just the url from the mainimage so a lightbox image will show.

<ul id="search_results">
                    <?php foreach ($results as $result): ?>
                    <li class="grid-x grid-margin-x search-result">
                        <div class="cell medium-2">
                            <?php if ($result->mainimage()->isEmpty()): ?>
    							<a href="/assets/resources/<?= $result->itemnumber() ?>.jpg" data-lightbox="<?= $result->itemnumber() ?>">
    								<img src="/assets/resources/<?= $result->itemnumber() ?>.jpg">
						    <?php else: ?>
						        <a href="NEED RESULT MAIN IMAGE URL HERE" data-lightbox="<?= $result->itemnumber() ?>">
                                    <?= $result->mainimage() ?>
						    <?php endif; ?>
                        <div class="cell medium-10">
                            <a href="<?= $result->url() ?>">
                                <?= $result->title()->itemnumber() ?>
                            <?= $result->shortdescription() ?>
                    <?php endforeach ?>

There is a default method that works called


Using it like below returned the image url for each result as expected.

<a href="<?= $result->imageurl() ?>" data-lightbox="<?= $result->itemnumber() ?>">