Render image from assets/images/ (and inline .svg)

Waht’s the current kirby3 and right way to render a brand logo image from assets/images/ in the header navigation???

Or is there a better way to store such global images instead in the assets/images/-folder (since it is not in the starter package) and refernce them …

I personally use:

<img src="<?= url('assets/images/logo.png')?>">
1 Like

If you need an asset object (for example, if you want to resize the image), you can use the Asset class

$logo = new Asset('assets/images/logo.png);
echo $logo->resize(200);

The asset() helper makes this even easier:

$logo = asset('assets/images/logo.png);
echo $logo->resize(200);
1 Like

Does K3 has the possibility to inline .svg files?
So that a <svg><path ....></svg>-tag gets inserted??

Yes, that’s possible with $file->read()

$logo = asset('assets/images/logo.svg');
echo $logo->read();
1 Like

nice :star_struck:

There’s even an inline svg() helper

<?= svg('assets/images/logo.svg') ?>

I think the Asset class and asset() helper are still undocumented - searching for them in the docs yields no results. :frowning:

Yes, that is true. There is already an open issue.