How to resize images

Hi have the following to display an image:

<?php if($image = $page->image('1-2-main.jpg')): ?>
           <img src="<?= $image->url() ?>" alt="">
     <?php endif ?>

I want to resize the image or create a thumbnail before displaying, how do I do that?

I tried

  <?php if($image = $page->image('1-1-main.jpg')): ?>
          echo <?= $image->resize(300) ?>
    <?php endif ?>

but that doesn’t change the size only the quality
Thanks for any help

I noticed you are missing a silicon

<?= $image->resize(300); ?>

You can try this <?= $image->crop(100) ;?>

@ODD_CODE The semicolon is not necessary in such one-liners.

@mdavid Check your stylesheet. If the image is set to 100% width and height, you won’t see a change in size on the frontend (it will only look blurry). And inspect the source code to see if the right image size is created.

Thanks Sonja, I’ve got alot to learn - but getting there.

My long term memory ain’t wot it used to be, but I forget that, so its ok.

Have a great day


1 Like