Hi - I'm trying to write an extension at the moment, and I'm seeing some behaviour that I don't understand and am hoping that someone can help explain...
Helped by some example code, I have the following extend.php:
`<?php
use Flarum\Extend;
use Flarum\Locale\Translator;
use Flarum\Post\Post;
use Illuminate\Support\Arr;
use s9e\TextFormatter\Utils;
return [
(new Extend\Formatter())
->render(function ($renderer, $context, $xml) {
return Utils::replaceAttributes($xml, 'IMG', function (array $attributes) use ($context): array {
$attributes['title'] = 'image_title';
$attributes['alt'] = 'image_alt';
$attributes['class'] = 'image_class';
return $attributes;
});
}),
];
I can see that this is partly working - it generates images in posts, looking like this:
<img src="http://somewhere.com/11f079522d2ac963197d7b46afabb703.jpg" title="image_title" alt="image_alt">`
The trouble I have though - why doesn't this set a class attribute in the img HTML tag? - if replaceAttributes doesn't allow class to be set - is there any other way that I can force an image to have a class?
Thanks,
Mike