How to get the width, height, mime type of an image?

#1

In v2, we were able to get the width, height, and mime type of an image by using these:

<?= $file->width(); ?>
<?= $file->height(); ?>
<?= $file->mime(); ?>

None of those appear to be working anymore since updating to v3 and I’m not seeing any replacement in the documentation.

Any advice?

0 Likes

#2

$file->dimensions() gives you an array containing the width, height, ratio and orientation keys.

$file->mime() will still work.

0 Likes

#3

Ah, looks like it wasn’t working because I forgot to use toFile(). I’m using $site->pwa_image()->toFile()->width() and it’s still working.

Side note: It looks like this page is missing $file->width and $file->height.

0 Likes