Actions

J1.5

Adding template overridable images in your extension

From Joomla! Documentation

Revision as of 04:14, 20 September 2010 by Batch1211 (Talk | contribs)

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Introduction

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

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

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

Details

  • 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

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