Documentation for $page->image()->html() missing

Hello everybody

I found this Core Change…

- New auto HTML tag generation for images: $page->image()->html()

… in Kirby 2.2.0 Release Notes, but can’t find any documentation on the Cheat Sheet. Any hints?

Thanks,
M.

This isn’t exactly documentation but it should help you out: https://gist.github.com/bastianallgeier/ccd90c483153f915a380

Best of luck! :grin:

<!-- create the complete html img tag for a given image -->
<?= $page->image()->html() ?>

<!-- modify the attributes of the img tag -->
<?= $page->image()->html(['class' => 'myImage']) ?>

<!-- resize an image first and then get the img tag for it -->
<?= $page->image()->resize(300,200)->html() ?>

<!-- crop an image first and then get the img tag for it -->
<?= $page->image()->crop(300)->html() ?>

Yes, unfortunately the Cheat Sheet is not yet updated to the latest Kirby release. We are working on it basically right now. :wink:

Hey mates

Thanks a lot for all your help. I’ll probably have to come up with my own field method then; do you know how to add methods to files in a similar way as field custom methods?

Cheerio,
M.

P.S. @lukasbestle: I’m constantly reading core code to get a better grip on its capabilities. Unfortunately there are a lot of technologies and concepts I’m not familiar with, e.g. dynamic methods, etc. Moreover the software architecture looks unfamiliar to my eyes. Is there a document where you explain some of them? Thanks again, Moritz

That’s currently not supported. You could however create a function that takes the object and put the function definition into a plugin:

echo myImageHtml($page->image());

There’s currently no documentation that explains the concepts of how Kirby works internally.
If you tell me what you want to know, I can try to explain that part here.

I was aware of the custom function approach, but with potential name space collisions et al I’m still missing a way to extend field methods. :slight_smile: Thanks again, Moritz

Yes, an official feature to extend the file object would definitely be a cleaner solution. I have created a feature request issue on GitHub.

Until then, the only way to do this is using a global function.

There is already an implementation by @distantnative.

1 Like

Great move, @distantnative. See you, M.