J1.5

Adding template overridable images in your extension

From Joomla! Documentation

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "J1.5" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Introduction[edit]

If you want to use images in your extension and you want to offer Joomla site administrators the option to customize it (via the template), this is the way to do it. Administrators or (template) designers will then be able to override your images via the template (images folder).

Code[edit]

Wherever you need the image (in html), use this code:

echo JHTML::_('image.site', 'myimage.png','/plugins/content/mypluginfolder/');

Details[edit]

  • This means that:
    • IF there is a template myimage.png found back at "[template folder]/images", use this one
    • IF NOT use the one in "/images/M_images".
  • This is for front end images, for back-end images replace "image.site" with "image.administrator".
  • Don't forget to insert the image in your extension's zip package and in the XML configuration file.
  • If you don't specify a folder, the folder "/images/M_images" will be initially searched for in the front-end, "/images" in the back-end.
  • If you want to know more: JHTMLImage is the class called by this JHTM.

Reference[edit]

Based on this forum topic: JHTML image.site; Where to put the fail back images ?