I have the code bellow. This is just an example. I try to get the padding for lazyloading, but I get an error on everything I do related to image height, width and ratio.
I know the padding is on the wrong div, but the error is in the php, so please don’t mind that.
What am I doing wrong?
<?php if ($element->slideshow()->isEmpty()): ?>
<?php if($image = $element->image()): ?>
<div class="lazyload" data-expand="-1000" >
<img class="placeholderimg lazyload" src="<?= $image->url() ?>" srcset="<?= $image->srcset([1]) ?>">
<img data-src="<?= $image->url() ?>" class="lazyimage lazyload" srcset="<?= $image->srcset([300, 500, 1000, 1500, 2000]) ?>">
<?php if($image = $element->image()): ?>
<?php $ratio = ($image->height() / $image-width() * 100) ?>
<div style="padding-bottom: <?php echo $ratio ?>% "></div>
<?php endif ?>
</div>
<?php endif ?>
<?php endif ?>