Can not use ->resize tag..!

Hi!..
this is my code and when I use “<?= $item->image()->resize(720) ?>”,
they said “Call to a member function resize() on null”…
how can I fix this…?
regards,

<?php 
    $tag = param('tag');
    $works = page('works');
    $items = null;
    if ($works) {
    $items = $works->children()->listed();}
    if ($tag) {
        $items = $items->filterBy('category', $tag, ',');
    }
?>

<?php if ($works = page('works')): ?>
        <?php if ($items && $items->isNotEmpty()): ?>
            <?php foreach ($items->paginate(7) as $item): ?>        
                        <figure>
                            <?= $item->image()->resize(720) ?>
                        </figure>
            <?php endforeach ?>
        <?php endif ?>
<?php endif ?>

Seems like one (or more) of the pages in your paginated collection does not have an image file attached. Hence, $item->image() returns null and then $item->image()->resize(720) triggers that error.

<?php if ($image = $item->image()) : ?>
<figure>
  <?= $image->resize(720) ?>
</figure>
<?php endif ?>