Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Difference between Asset::img() and Html::img()
  • Hello everybody, What is the difference between Asset::img() and Html::img() ? And if there are no difference, why we have 2 ways to do the same thing.
  • Html::img() just generates the <img> tag, with as source whatever you pass as parameter. Asset::img() expects a base name (like 'icons/google.png') which the Asset class will convert to the source for the <img> tag based on it's configuration. So the first one is hard-coded (like hard coding your HTML yourself), the second one is dynamic, and allows you to switch asset locations (the Theme class uses this mechanism to switch assets when you switch themes), or to switch from local files to static files (other subdomain) or a CDN, without changing your application code.

Howdy, Stranger!

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

In this Discussion