I am building a Joomla 3.x module, I have used a media type field within the module params

<field name="image-1" type="media" label="Select your first image" directory="backgrounds" />

This is showing up within the XML file for the module, but how can I echo this (when it's completed) in the front end?


You access the parameter like you would any other parameter like so:


And to display the image, you can use the following:

<img src="<?php echo JUri::root() . $params->get('image'); ?>" alt="" />

You can see that I've used JUri::root() to define the root of your Joomla path.

| improve this answer | |
  • You're welcome @RustyJoomla – Lodder Dec 2 '14 at 10:07

This is how I do it:

  1. Set the position of your module to "whateveryouwant" (lets call it 'custommod01')

  2. Go to the article manager or wherever you'd like to see the module and write this into the text editor:

    {loadposition custommod01}

(If your using a plain HTML editor make sure you wrap it in <p> tags.)

Also if you wrap this code within a <div>, you can style the div and set attributes to this module dynamically per-page

| improve this answer | |
  • 1
    You've explained how to display a moduel - the question was how to echo an image within the module :) – GDP Dec 2 '14 at 15:45
  • Thanks for answering josh.thomson, but as @Lodder says this would load a module, not what was required but thanks for taking the time. – RustyJoomla Dec 2 '14 at 17:24

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.