This will automatically render any image urls in the torrent description as a HTML image tag. Images will show right away. Also, domain is listed under each image.
HTML can be replaced with BBCode (edit the markup).
Add to backend/functions.php:
Open torrents-details.php and find:
Replace with:
Example:
HTML can be replaced with BBCode (edit the markup).
Add to backend/functions.php:
function format_media(string $body): string
{
$i = 0;
return preg_replace_callback('~(http.*\.)(jpe?g|png|[tg]iff?|svg)~i', function($matches) use (&$i)
{
$i++;
if (isset($matches[3])) {
return "<a href='{$matches[2]}{$matches[3]}' target='_blank'><img src='{$matches[2]}{$matches[3]}' style='width:90px;height:90px;border-radius:4px'></a>";
} else {
$domain = parse_url($matches[1], PHP_URL_HOST);
return "<div style='padding:5px;background:#d2d2d2;border-radius:4px;width:150px'><a href='{$matches[1]}{$matches[2]}' target='_blank'><img src='{$matches[1]}{$matches[2]}' style='width:100%;height:90px;border-radius:4px'></a><div style='text-align:center;margin-top:-3px'>$i - $domain</div></div>";
}
}, format_comment($body));
}
Open torrents-details.php and find:
print("<tr><td align='left' colspan='2'><b>" .T_("DESCRIPTION"). ":</b><br />" . format_comment($row['descr']) . "</td></tr>\n");
Replace with:
print("<tr><td align='left' colspan='2'><b>" .T_("DESCRIPTION"). ":</b><br />" . format_media($row['descr']) . "</td></tr>\n");
Example:
Last edited by STorrents2020 on 2022-11-25 21:38:53
