0

I do not get the images out of my article. The article var is initialized, but the images and pictures vars seem to be empty. Any hints what I do wrong here?

<?php
   $id = JFactory::getApplication()->input->getInt('id');
   $article = JTable::getInstance("content");
   $article->load($id);
   $images = $article->item->images;
   echo $images;
   $pictures = json_decode($images);
   echo $pictures;
?>

<?php echo $pictures->image_intro; ?>
  • So what, of the above, is being printed to screen? Which lines is generating a warning/notice/error? – mickmackusa May 15 at 23:08
  • Is the code part of template override, module or something else? – webchun May 16 at 3:35
4

When developing, error reporting should be enabled. You'll see this:

Notice: Undefined property: Joomla\CMS\Table\Content::$item

Access the images like this:

$images = $article->images;
  • "When developing, error reporting should be enabled." - This is more useful advise than the corrected piece of code below it ;) – FFrewin May 16 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.