how to display article intro image in joomla module?

Article display by yourtheme/html/com_content/article/tmpl/default.php file.

you can use module mod_articles_latest so edit mod_articles_latest/tmpl/default.php file.

<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_latest
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
?>
<ul class="latestnews<?php echo $moduleclass_sfx; ?>">
<?php foreach ($list as $item) : ?>
<li>
<a href="<?php echo $item->link; ?>">
<?php echo $item->title; ?></a>
<img src="<?php echo json_decode($item->images)->image_intro; ?>"/> //new line
</li>
<?php endforeach; ?>
</ul>
Advertisements

One thought on “how to display article intro image in joomla module?

  1. Thanks for this, using it with the newsflash module. Only one thing: is there a way for <img src="images)->image_intro; ?>”/> to handle articles without intro image? Right now I get a broken image icon if no intro image is assigned to the article. I’m a total PHP noob…is there a way to add some “if image url empty then do not display” ?
    Thanks

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s