V
V
Valentin Melnik2018-11-03 15:21:23
Joomla
Valentin Melnik, 2018-11-03 15:21:23

How to check if an image exists in Joomla 3.x?

Hello.
My news output is as follows

<div class="col-sm-6 minor">
      <a class="title-news-minor" href="<?=$item->link?>">
        <img src="<?=$images->image_intro?>" alt="<?=$item->title?>" title="<?=$item->title?>" class="no-lightbox">
        <<?=$item_heading?>><?=$item->title?></<?=$item_heading?>>
      </a>
      <p class="date-news"><?php echo $item->created;?></p>
    </div>

How to make it check for the presence of the image_intro image? Now if there is no picture, then the image of a broken picture.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valentin Melnik, 2018-11-04
@Poincare

Thanks for the tip. I did it with pictures

<div class="col-sm-6 minor">
        <a class="title-news-minor" href="<?=$item->link?>">
        	<?php if(isset($images->image_intro) && $images->image_intro !== '')  {
        		?>
           <img src="<? echo $images->image_intro; ?>" alt="<? echo $item->title; ?>" title="<?echo $item->title; ?>" class="no-lightbox">
           <?
      } ?>
          <<?=$item_heading?>><?=$item->title?></<?=$item_heading?>>
        </a>
        <p class="date-news"><?php echo $item->created;?></p>
      </div>

S
Sergey Goryachev, 2018-11-03
@webirus

The questions are too simple.
And most importantly, everything is googled in 5 minutes.
I know, because I myself once looked for exactly the same questions.
Correct check for emptyness of a variable?

if(isset($var) && $var !== '')  {
// $var не null и не  ''.
}

I don't see any tag output in the code at all. They may be included, but I do not see that they were displayed.
to help. There are all the variables, see what you need and put in the template.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question