Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
New Asset Type
  • Hello, 

    Is there a way to specify a new asset type within the asset config file? I've been looking at the asset docs, and I don't currently have a solution. 

    ex: Asset::uploads('title_cards/card1.png');
  • You can call add_type() in the Asset instance to add a new type, after which you can call find_file() or get_file() to get URL's to files of the new type.
  • Can you please give me an example? 
  • HarroHarro
    Accepted Answer
    Assuming you're not using custom instances:

    \Asset::instance()->add_type('test');
    $url = \Asset::instance()->get_file('filename.png', 'test');

    Will return <assetpath>/test/filename.png (if this file exists).
  • Thank you, that works fine. 

    But, is there any way to be able to define a new type, like Asset::uploads? and define 'uploads' so I can use it anywhere in the application like I would Asset::img, Asset::js, etc.
  • HarroHarro
    Accepted Answer
    You will have to extend the Asset class (to provide the static interface) and the Asset_Instance class (to provide the actual method).

    Check http://docs.fuelphp.com/general/extending_core.html#extend_and_replace on how to go about extending the core.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion