News:

Looking for documentation? Take a look on our wiki

Main Menu

How to include an image with a plugin

Started by pldev, August 21, 2012, 10:51:51 AM

Previous topic - Next topic

pldev

I've created a payment plugin, and I want to include an image within the install for that plugin.

In the install_script.xml I have the parts that lets me install the language files and the main code (php) and configuration (xml) file, but how to I also include an image?

Extracts from the install_script.xml:


<install version="1.5" type="plugin" group="vmpayment">
  <files>
    <filename plugin="modulename">modulename.xml</filename>
    <filename plugin="modulename">modulename.php</filename>
  </files>
  <languages>
    <language tag="en-GB">en-GB.plg_vmpayment_modulename.ini</language>
    <language tag="en-GB">en-GB.plg_vmpayment_modulename.sys.ini</language>
  </languages>
</install>


This copies the xml and php files to plugins/vmpayment/modulename/ and the ini files to administrator/language/en-GB/

So if I want to put image.jpg into images/stories/virtuemart/payment/ what do I need to add to the above install_script.xml?


ivus

Hi pldev,

Wrong forum (it's a Joomla! thing), but I'll help you anyway.

Firstly you don't need to put it in the "images/stories/virtuemart/payment/" folder. It'll serve perfectly fine from inside your plugins folder.

Create a folder within your plugins folder and call it "assets", dump all you images in there and include the reference in your .XML file as such.

    <files>
      <filename plugin="modulename">modulename.php</filename>
      <folder>assets</folder>
      <filename>index.html</filename>
    </files>

When you zip it up, be sure to include that folder with it. During the installation process it should now know to create that folder and dump all the files into it.

I hope this helps. ;D

bytelord

Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

pldev

OK, got it working now using an install script - thanks for the pointers.

Seems a lot of work to do just to get one image installed, which does have to go into the 'images/stories/virtuemart/payment/' directory and not into any assets type directory etc, as that is where VirtueMart displays the payment logos from on the checkout pages. If you put the images anywhere else then they don't display (you just get the broken image indicator)




alatak

Hello

QuoteIf you put the images anywhere else then they don't display (you just get the broken image indicator)
It should not.
It is the plugin itself that render the plugin name, so you can decide where your images should be.

For the Paypal plugin they are in the images/stories/virtuemart/payment/ folder, but it is not mandatory.