I have a simple Joomla 3 plugin that works fine on backend for resizing images when uploading from multimedia manager:


defined('_JEXEC') or die('Restricted access');

class PlgContentProcesador extends JPlugin
    protected $allowedMimeTypes = array('image/jpeg', 'image/png', 'image/gif');

    public function onContentAfterSave($context, $article, $isNew)
        if ($context == 'com_media.file') {
            JFactory::getApplication()->enqueueMessage('Filepath: ' . $article->filepath);
            if ($article->type == 'image/jpeg' or $article->type == 'image/png') {
                $orig_image = new JImage($article->filepath);
                // 750 will be set accordind to image ratio depending on 1000
                $resized_image = $orig_image->resize(1000, 750, true, JImage::SCALE_INSIDE);

I need to work the same on upload frontend in article submission, but when changing the context to com_content.form, nothings works. The variable $article seems not retrieve any data.

Any suggestions?

  • Though not an issue for this snippet, I would urge you to not use or in conditions with multiple expressions because or has the lowest precedence of all operators and can sometimes cause buggy/unexpected problems. Welcome to JSE and please take our tour. Jan 24, 2022 at 21:11
  • Have you checked the value of $article? It should be an instance of Joomla\CMS\Table\Content. It's not going to have the same properties as a media file.
    – Sharky
    Jan 26, 2022 at 18:48
  • How can I check that value? I tried with var_dump but nothing showing up. Jan 27, 2022 at 14:31
  • You need to exit after var_dump() because a redirect is performed afterwards.
    – Sharky
    Jan 28, 2022 at 9:55
  • Thank you. Now I can see that the $article variable doesn't contain the path, so I'll try another approach to the problem. Jan 28, 2022 at 14:15

1 Answer 1


I think you just need to pass the $article parameter in as a reference. Add a & before the $article variable in the function call.

So, to change...

public function onContentAfterSave($context, $article, $isNew)


public function onContentAfterSave($context, &$article, $isNew)
  • Tried, but not working. Jan 25, 2022 at 13:32
  • Hmm, I'll have a bit more of a think Jan 25, 2022 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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