I am trying to customize the the category list of my website. So I have a menu option that shows the list of all article is a certain category. In this list I would like to show the into image of the article too. But unfortunately I cannot find the path of this intro image of each article to put it in the '' tag.
This code takes the first image in the article. Which is not what I want.
<?php
$text = $article->introtext;
if(preg_match('/<\s*img[^>]+>/Ui', $text, $matches)){
$image=$matches[0];
$text = str_replace($image,'',$text);
}
if ($matches) {
$image = str_replace('img src="','img width="150px" src="/demo/persianlondon/',$image);
$image = str_replace("caption","", $image);
echo '' . $image . '';
}
else {echo '<img width="150px" src="http://goo.gl/k47rNN" class="defaultArticleImage" />';}
?>
So I need to get the intro image url and set it for $image. Any idea to do it?
$article->introtext
contain? I am sure I can provide you with an optimized solution if you can clarify the posted question.