VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: pldev on August 21, 2012, 10:51:51 AM

Title: How to include an image with a plugin
Post by: pldev on August 21, 2012, 10:51:51 AM
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?

Title: Re: How to include an image with a plugin
Post by: ivus on August 21, 2012, 11:25:28 AM
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
Title: Re: How to include an image with a plugin
Post by: bytelord on August 21, 2012, 11:28:26 AM
Hello,

That's a joomla thing :)

take a look here: http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Adding_an_install-uninstall-update_script_file

You should read the joomla developer guides maybe :)
Title: Re: How to include an image with a plugin
Post by: pldev on August 21, 2012, 15:17:52 PM
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)



Title: Re: How to include an image with a plugin
Post by: alatak on August 21, 2012, 19:24:23 PM
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.