I had an issue with the Flamoji extension (https://discuss.flarum.org/d/28095-flamoji ), specifically with the custom emojis, since they are images, 90% of the threads had a custom emoji before any other image, you can imagine the result on the homepage.
In order to fix that, I changed AddDiscussionThumbnail.php editing this block of code
preg_match('/<img.+?src=[\"\'](.+?)[\"\'].*?>/i', $content, $match);
$thumbnail = @$match[1];
$this->cache->forever($key, $match ? [
'url' => @$match[1],
'date' => $post->edited_at,
] : null);
to this ("assets/emoticons" is the folder inside /public where I have stored my custom emojis)
preg_match_all('/<img.+?src=[\"\'](.+?)[\"\'].*?>/i', $content, $matches);
foreach ($matches[0] as $myKey => $match) {
if (strpos($match, "assets/emoticons") == false) {
$thumbnail = @$match;
$this->cache->forever($key, $match ? [
'url' => @$matches[1][$myKey],
'date' => $post->edited_at,
] : null);
}
}
and it works fine, it skips every image that has 'assets/emoticons' without affecting the extension behaviour.
Is there a cleaner way to do this? Like using extend.php?