Answer the question
In order to leave comments, you need to log in
Yii2 -> getimage() -> how to remove no-image image if there is no product image?
Valar Morghulis!
I display "about the company" and in some places there is a picture, in some places there is not. How to correctly set the condition for this case (there is or is not a picture)
<?php foreach($about as $about2): ?>
<?php $mainImg = $about2->getImage();?>
<?= $about2->content?>
<?php if(!$mainImg->getUrl()): ?>
<?= Html::img($mainImg->getUrl('653x612'), ['alt' => $about2->name])?>
<?php endif;?>
<?php endforeach;?>
Answer the question
In order to leave comments, you need to log in
If I understand the question correctly, thenif( !empty($mainImg->getUrl()))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question